Re: Changing the directory that PHP runs from (CLI)

From: Date: Fri, 11 Jun 2004 14:42:17 +0000
Subject: Re: Changing the directory that PHP runs from (CLI)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-188105@lists.php.net to get a copy of this message
Phil Ewington - 43 Plc wrote:
Hi All, I have read the manual page for 'Using PHP from the command line' thoroughly and cannot find the answer to my problem. I have a script that needs to be accessed from both the command line and from web browsers. I tested the script from the command line and all worked well. As soon as I set the script to run from the crontab, all my includes fail because of paths. I believe the manual tries to cover forcing PHP to run from an alternative location but makes no sense to me. Can anyone tell me what changes I need to make to the following crontab entry... 0 23 * * * /usr/bin/php /path/to/my/script.php arg1 arg2 arg3 > /dev/null TIA - Phil. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Well, you could put your includes in a central location and set the include_path correctly in your php.ini. If that won't work for you, you can use chdir(dirname(realpath(__FILE))) to change to the script's directory. You could also use ini_set to add whatever directory you need ot the script's include_path. -- paperCrane <Justin Patrin>

« previous php.general (#188105) next »