且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP CLI include()找不到文件

更新时间:2023-11-16 23:23:16

这是因为当前工作目录是您在其中调用命令的目录,而不是脚本所在的目录.

That's because your current working directory is the one you call your command at, not the one your script is located in.

使用

require __DIR__ . '/../config.php';

相反. __DIR__是指向当前文件所在目录的const.

instead. __DIR__ is a const that points to the directory current file is located in.