简体   繁体   中英

cron won't run PHP because of forward slash

Alright, so I've got a cron job that is supposed to run a PHP file every minute, I'm hitting the file and getting an error that I'm not sure how to fix exactly; the server (Debian) will not recognize PHP's include if there is a '/' located anywhere in the link.

I've been searching for an answer for this for about an hour and a half and keep running up nothing. Hopefully you guys could lend me a hand

Please use absolute file path. If the "include" files are relative to the "main.php", you can use

include(dirname(__FILE__)."/mysubdir/myincfile.php");

The more elegant way about filesystem "slashes" is to use , eg, ,例如,

include(dirname(__FILE__).DIRECTORY_SEPARATOR."mysubdir".DIRECTORY_SEPARATOR."myincfile.php");

The better yet way to handle directories is to "define" them:

if(!defined('MYROOTDIR'))
{ 
   define('MYROOTDIR',(dirname(__FILE__).DIRECTORY_SEPARATOR."mysubdir"));
}
include(MYROOTDIR."myincfile.php");

Thank you,
Tom

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