is_dir 检查不起作用
我在使用/理解 is_dir 时遇到一些问题。 (是的,我已经阅读了 PHP 文档)。
我有一个如下的 baseDIR:
$baseDIR = 'I:\Development\wamp\www\mySite\wp-content\uploads\'
以下代码是 TRUE,因此输出文本:
if (is_dir($gallery->baseDIR))
echo 'DIR exists';
现在我需要检查是否有一个名为“f”的目录(是的,只有一个字符)。 但以下代码返回 false:
if (is_dir($gallery->baseDIR.'f\\'))
echo 'DIR exists';
当目录存在时,为什么不返回 true?
我正在 Win XP 上进行开发,但我的 ISP 产品服务器是 Unix。
更新:
回显 $gallery->baseDIR.'f\' 给出以下输出:
I:\Development\wamp\www\mySite\wp-content\uploads\f\
更新 2:
我不得不承认,经过 12 个小时的工作,我已经很累了,而且现在已经过了午夜了。 我犯了一个简单的愚蠢错误。 我忘记将图像文件夹添加到基本目录中......
$baseDIR = 'I:\Development\wamp\www\mySite\wp-content\uploads\slgallery\'
I'm having some problems using / understanding is_dir. (Yes, I have read the PHP doc).
I have a baseDIR as following:
$baseDIR = 'I:\Development\wamp\www\mySite\wp-content\uploads\'
The following code is TRUE and therefore outputs the text:
if (is_dir($gallery->baseDIR))
echo 'DIR exists';
Now I need to check if there is a directory called 'f' (yes, just one character). But the following code returns false:
if (is_dir($gallery->baseDIR.'f\\'))
echo 'DIR exists';
Why is this not returning true, when the dir exists?
I'm developing on Win XP, but my ISP prod server is Unix.
Update:
Echoing $gallery->baseDIR.'f\' gives me the following output:
I:\Development\wamp\www\mySite\wp-content\uploads\f\
Update 2:
I have to admit that I'm tired after 12h of work and it's way past midnight. Simple STUPID mistake from me. I had forgoten to add he image folder to the base dir....
$baseDIR = 'I:\Development\wamp\www\mySite\wp-content\uploads\slgallery\'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是
open_basedir
限制。 通过执行 phpinfo() 检查设置,此设置通常在启用 safe_mode 时出现。It could be an
open_basedir
restriction. Check the setting by executing phpinfo(), this setting is usually present when safe_mode is enabled.