When running from the CLI, PHP exhibits some different behaviours than when run from a web server. These differences should be kept in mind, especially in the case where the same script might be run from both environments.
require("./stuff.inc");
assumes the file is in the same directory as the script. On the command line, the current working directory is the directory you're in when you call the script. Scripts that are going to be called from the command line should always use absolute paths. (Note the magic constants __DIR__
and __FILE__
continue to work as expected, and return the location of the script.)php.ini
directives output_buffering
and implicit_flush
default to false
and true
, respectively. Buffering is still available, but must be explicitly enabled, otherwise output will always be displayed in real time.php.ini
directive max_execution_time
is set to zero, so scripts will not time out by default.php.ini
directive html_errors
, it will be ignored on the command line.php.ini
can be loaded. When you are using php from cli it can use different php.ini
than web server do. You can know what file is using by running php --ini
.