我试图从不同的文件夹中的PHP文件需要我的“库”文件,但试图从一个子文件夹访问它们时,它提供的错误。 例如,我有这样的目录:
+ home
- file1.php
++ subfolder
- file2.php
++ libraries
- code_generator.php
- database_library.php
code_generator.php还取决于其他图书馆:
(LINE 25) require_once(realpath("./libraries/database_library.php"));
//this works fine when called from file1.php, but not from file2.php
我尝试调用code_generator从./subfolder/ file2.php喜欢:
chmod("../libraries/codegenerator.php", 0777); // for the error at the end of this question
require_once("../libraries/code_generator.php");
当我运行file2.php,它产生2个错误:
**Warning**: require_once(C:\xampp\htdocs\home\subfolder): failed to open stream: Permission denied in C:\xampp\htdocs\home\libraries\code_generator.php on line 25
**Fatal error**: require_once(): Failed opening required '' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\home\libraries\code_generator.php on line 25
*第25行是require_once(realpath("./libraries/database_library.php"));