首页 > 后端开发 > php教程 > 没有调用为什么页面里会有值

没有调用为什么页面里会有值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-06 20:19:36
原创
1234 人浏览过

<code><?php // $Rev: 129 $
//error_reporting(E_ALL);

foreach (new DirectoryIterator(getcwd()) as $entry) {
    if ($entry->isFile() && strpos($entry, '_testcase.')>0) {
        echo basename($entry);
        require_once($entry);
        echo '<br>...pass!<br><br>';
    }
}
?></code>
登录后复制
登录后复制

这样一段代码。在一个cms里看到的。 为什么访问的时候会报错

<code>element_testcase.php
Warning: require_once(../../simple_html_dom_reader.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\web\inc\simplehtmldom_1_5\testcase\reader\element_testcase.php on line 6

Fatal error: require_once(): Failed opening required '../../simple_html_dom_reader.php' (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\web\inc\simplehtmldom_1_5\testcase\reader\element_testcase.php on line 6</code>
登录后复制
登录后复制

我的意思是报错。。说明有值,但是这个页面没调用别的文件,而且 DirectoryIterator这个类和getcwd()这个函数,我全文搜索都找不到。

在说明一下,把上面的代码复制,新建一个php文件,在访问,就是空了,,这是为什么呢???

回复内容:

<code><?php // $Rev: 129 $
//error_reporting(E_ALL);

foreach (new DirectoryIterator(getcwd()) as $entry) {
    if ($entry->isFile() && strpos($entry, '_testcase.')>0) {
        echo basename($entry);
        require_once($entry);
        echo '<br>...pass!<br><br>';
    }
}
?></code>
登录后复制
登录后复制

这样一段代码。在一个cms里看到的。 为什么访问的时候会报错

<code>element_testcase.php
Warning: require_once(../../simple_html_dom_reader.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\web\inc\simplehtmldom_1_5\testcase\reader\element_testcase.php on line 6

Fatal error: require_once(): Failed opening required '../../simple_html_dom_reader.php' (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\web\inc\simplehtmldom_1_5\testcase\reader\element_testcase.php on line 6</code>
登录后复制
登录后复制

我的意思是报错。。说明有值,但是这个页面没调用别的文件,而且 DirectoryIterator这个类和getcwd()这个函数,我全文搜索都找不到。

在说明一下,把上面的代码复制,新建一个php文件,在访问,就是空了,,这是为什么呢???

  1. 这个报错是在告诉你 simple_html_dom_reader.php 无法加载,你应该检查require_once是不是路径有问题,或者文件是否已经删除

  2. DirectoryIterator 是PHP的内建类,请看 http://php.net/manual/zh/class.directoryiterator.php 用于对目录的迭代,getcwd是获取当前工作目录,PHP内建方法

  3. 其实这个时候你用xdebug单步调一下或者运行个跟踪分分钟就知道问题出在哪里。。。

相关标签:
php
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
怎么学好php
来自于 1970-01-01 08:00:00
0
0
0
PHP扩展intl
来自于 1970-01-01 08:00:00
0
0
0
php数据获取?
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板