Scandir 一去不复返
我正在使用 Windows 7 机器进行开发,本地服务器是 UniServer。
我有一些 PHP 代码来包含目录中的所有 php 文件。
# Include all library classes.
$library_files = scandir(LIBRARY_PATH);
foreach ($library_files as $file) {
$path_parts = pathinfo($file);
if ($path_parts['extension'] == 'php') {
require(LIBRARY_PATH . DIRECTORY_SEPARATOR . $file);
}
}
调用 scandir 函数会导致脚本永远不会结束。不知道是不是文件夹权限的问题。我可以包含文件夹中的文件。
这里出了什么问题?谢谢。
编辑:LIBRARY_PATH 等于 E:\Tools\UniServer\www\LIBRARY
编辑:显然它现在正在工作。我很困惑,我根本没有改变任何事情。我想我可能需要重新安装 PHP。感谢您的帮助
I am developing using a Windows 7 machine with the local server being UniServer.
I have some PHP code to include all php files in a directory.
# Include all library classes.
$library_files = scandir(LIBRARY_PATH);
foreach ($library_files as $file) {
$path_parts = pathinfo($file);
if ($path_parts['extension'] == 'php') {
require(LIBRARY_PATH . DIRECTORY_SEPARATOR . $file);
}
}
Calling the scandir function causes the script to never end. I am not sure if this is a problem with the permissions of the folder. I am able to include files from within the folder.
What is going wrong here? Thankyou.
Edit: LIBRARY_PATH equals E:\Tools\UniServer\www\LIBRARY
Edit: Apparently it is working now. I'm confused, I haven't changed anything at all. I think I might need to reinstall PHP. Thanks for helping
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点含糊。
您是否尝试过从 CLI 运行脚本,在 scandir 之后写入 stdout 并在进入循环之前刷新输出缓冲区?
如果您尝试在命令提示符下 DIR E:\Tools\UniServer\www\LIBRARY 会发生什么情况?
当您在 PHP 脚本中尝试
DIR E:\Tools\UniServer\www\LIBRARY
时会发生什么?A bit vague.
Have you tried running the script from the CLI, writing to stdout after scandir and flushing the output buffer before entering the loop?
What happens if you try to DIR E:\Tools\UniServer\www\LIBRARY at the command prompt?
What happens when you try
DIR E:\Tools\UniServer\www\LIBRARY
within a PHP script?