小编Ras*_*had的帖子

PHP:包含和要求文件时抛出错误

我试图创建一个bootstrap文件,但每当我尝试在另一个文件中包含或要求它时,这样的错误会一直显示:

警告: require_once(../ folder/file.php)[function.require-once]:无法打开流:没有这样的文件或目录...

致命错误: require_once()[function.require]:在...中打开所需的'../folder/file.php'(include_path =':')失败

绘制整个场景:我有一个bootstrap文件,load.php.在其中,我连接到../config/config.php的配置文件.在加载文件上方,我在classes/database.php中有一个数据库类文件.在数据库文件中我写了这个if语句:

           if ( file_exists('../load.php') ) {
               echo 'load.php: It exists';
               require_once('../load.php');
           } else {
                  echo 'load.php: It does not exist';
                  }
Run Code Online (Sandbox Code Playgroud)

在加载文件中,我写了一个类似的if语句,但检查配置文件是否存在.令人惊讶的是,当我加载database.php文件时,我得到:

load.php: It exists
config.php: file doesn't exist
Run Code Online (Sandbox Code Playgroud)

但是当我加载load.php文件时,我得到:

config.php: It exists
Run Code Online (Sandbox Code Playgroud)

这是我的文件所在的位置:

根目录:/Library/WebServer/Documents/project

config.php文件 /Library/WebServer/Documents/project/config/config.php

load.php文件: /Library/WebServer/Documents/project/includes/load.php

database.php文件:/Library/WebServer/Files/project/includes/classes/database.php

我需要帮助解决这个bug.谢谢,

php directory require include

5
推荐指数
1
解决办法
1974
查看次数

有条件地包括Angular App中的侧边栏和标题

在某些视图中,我想要一个侧边栏和标题,有些我不想.使用AngularJS,实现这一目标的最佳方法是什么.

我当前的解决方案是在侧边栏和标题DIV上使用ng-if,并在我的控制器中,将$ scope变量设置为true或false,具体取决于我希望侧边栏和标题显示的视图.

一个具体的例子是Youtube.com.在Youtube的主页上,请注意有一个侧边栏和一个带有过滤器的子标题:"要注意什么"和"音乐".但是,在任何视频页面上,侧边栏和子标题都不存在.我想在AngularJS中实现这一点.

的index.html

    <html ng-app="demoApp">

    <body ng-controller="demoAppMainController">

        <header>
            <ng-include src="'./partials/mainHeader.html'"></ng-include>
            <ng-include ng-if="showSubHeader" src="'./partials/mainSubHeader.html'"></ng-include>
        </header>

        <main>
            <ng-view></ng-view>
        </main>


    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)

discussionBoard.html

    <div class="discussionBoard" ng-controller="DiscussionBoardController">
         <h2>DiscussionBoard</h2>
    </div>
Run Code Online (Sandbox Code Playgroud)

controllers.js

    var demoAppControllers = angular.module('demoAppControllers', []);

    demoAppControllers.controller('demoAppMainController', ['$scope', function($scope) {
            $scope.showSubHeader = true;
    }]);

    opinionLensControllers.controller('DiscussionBoardController', ['$scope', function($scope) {
            $scope.showSubHeader = false;
    }]);
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-ng-include angular-ng-if

2
推荐指数
1
解决办法
2887
查看次数