简体   繁体   中英

PHP script (include) not working from command line

I have a php script that works perfectly fine when run by the web server but when I run the script from the command line (or as a cron job) then it fails to find the file. The code that errors out is:

include('fpdf181/fpdf.php');

I tried including DIR but that does not work either

include(__DIR__ .'fpdf181/fpdf.php');

Can someone tell me how to include files for a script that will run from the command line

can you see this ( PHP Cron Job: Including file not working? )

as the link, you use "require" and not include

Code: require('./fpdf181/fpdf.php')

happy codeing.

您可以使用文件的完整路径(独立于当前目录/ env)。

include('/path/to/lib/fpdf181/fpdf.php');

我能够通过在目录上执行cwd并转到放置脚本的文件夹来执行我的脚本

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM