此代码显示./列出的文件。 如您所见,它显示了文件test.php
$dir = './';
$files1 = scandir($dir);
print_r($files1);
Array
(
[0] => .
[1] => ..
[2] => xxx.php
[3] => xxx.php
[4] => xxx.php
[5] => test.php
[6] => xxx.html
[7] => .htaccess
[8] => index.php
[9] => license.txt
[10] => xxx.html
[11] => xxx.php
[12] => xxx.html
[13] => xxx.jpg
[14] => xxx.xml
[15] => xxx.xml.gz
[16] => xxx
[17] => wp-activate.php
[18] => wp-admin
[19] => wp-blog-header.php
[20] => wp-comments-post.php
[21] => wp-config.php
[22] => wp-config-sample.php
[23] => wp-content
[24] => wp-cron.php
[25] => wp-includes
[26] => wp-links-opml.php
[27] => wp-load.php
[28] => wp-login.php
[29] => wp-mail.php
[30] => wp-settings.php
[31] => wp-signup.php
[32] => wp-trackback.php
[33] => xmlrpc.php
)
但是,当我运行脚本时,它会找不到错误文件:
echo "Running test...<br />";
$filename = './test.php';
require $filename;
跑步测试...... 错误:没有这样的文件或目录
它给出了错误但它实际上在include文件中运行了SQL代码。 我无法弄清楚为什么会这样。我在2个文件中都没有任何其他require命令。 SQL存储在数据库中并从插件“Wordpress包含PHP在帖子中”运行 这会以某种方式改变路径吗?它会运行include命令然后显示找不到文件的错误,这似乎很奇怪。