I wrote a script to gather certain configuration data from our servers to compare different environments. For this I get the PHP settings using php -i command.
I noticed now that the output of 'php -i' does not show the same values as inside the loaded php.ini file.
# /usr/local/zend/bin/php -c /usr/local/zend/etc/php.ini -i | grep -E -e 'Configuration File|max_exec'
Configuration File (php.ini) Path => /usr/local/zend/etc
Loaded Configuration File => /usr/local/zend/etc/php.ini
max_execution_time => 0 => 0
# cat /usr/local/zend/etc/php.ini | grep max_exec
max_execution_time=1200
Note that this is php CLI only, there is no server involved. I verified the following things:
- there are other .ini files scanned but none of them contains the max_execution_time directive.
- php -i does not report a syntax error inside the php.ini (as other questions mentioned as a possible problem)
You cannot set
max_execution_timefor CLI. See the manual, in the section "Overridden php.ini directives":In other words, no matter what you set for
max_execution_timeinphp.ini, CLI wil override it to be unlimited.If you want to limit the execution time for a script, you can use the
set_time_limit()function in your script itself.