需要一个目录而不是一个文件?

时间:2015-07-29 15:37:06

标签: php

我收到了这条错误消息:

Warning: require(/home/victor/public_html/plugindev/wp-includes/plugin.php): failed to open stream: Not a directory in /home/victor/public_html/plugindev/wp-settings.php on line 75

Fatal error: require(): Failed opening required '/home/victor/public_html/plugindev/wp-includes/plugin.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/victor/public_html/plugindev/wp-settings.php on line 75

但是...

 ~  stat /home/victor/public_html/plugindev/wp-includes/plugin.php 
File: ‘/home/victor/public_html/plugindev/wp-includes/plugin.php’
➜  ~  stat /home/victor/public_html/plugindev/wp-settings.php
File: ‘/home/victor/public_html/plugindev/wp-settings.php’

和最奇怪的部分,随机发生和随机文件,都存在。 (即已经看到其他文件的错误相同)

我认为与我正在开发的插件不兼容,但不知道如何调试

1 个答案:

答案 0 :(得分:1)

这里显然存在权限问题。

<?php
$dir = '/path/to/dir';
$file = $dir . '/file.ext';

echo is_readable($dir)
    ? "Dir is readable"
    : "Dir is not readable";

echo is_readable($file)
    ? "File is readable"
    : "File is not readable";

这段代码会告诉您是否存在权限问题,并且您可以正确解析代码。如果它是随机的&#39;那么当你尚未生成文件时,你可能希望文件存在吗?如果是这种情况,可以使用上面的检查代码来指示是否需要创建文件。