开发者

require_once() Error in linux (apache2)

While i try to deploy the code devloped on wamp server on the dev machine on linux , i get this error: Warning: require_once(/PHP file) [function.require-once]: failed to open stream: No such file or directory in /var/www/proj/index.php on line 38

Fatal error: require_once() [function.require]: Failed opening required '/PHP file' (include_path='.:/var/www/proj:/var/www/proj/framework:') in /var/www/proj/index.php on line 38

Now the PHP file i called is in the path "/开发者_Python百科var/www/proj/framework"


You have just supplied wrong filename.
Use proper path to this PHP file


require_once("/PHP file")

is using an absolute path and looking for PHP file in the server's filesystem root directory

require_once("./PHP file")

or

require_once("PHP file")

is a relative path that would search for PHP file using the include path


Also, to necromance this thread even further, don't forget Windows doesn't care about case-sensitivity, and Unix/Linux does!


This work for me, using the magic const of PHP

require once __DIR__ . "/directory/name_file.php";



I have also faced the same problem earlier.
I found on my program that, all path was included using "\" on Windows system and linux supports "/" path separator.
Please check once that all you include path is having "/" path separator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜