Search on DDG and in here didn't get any interesting results. I've heard they're different, but I want to know what makes them different and what advantage is there in having two different configurations ?
EDIT : Yes, I am running them both from the CLI.
phpinfo()
is a language function that will display its output regardless of whether the script that it's executed in is called through the web SAPI or from CLI;
php -i
is purely a command line switch to get information about PHP from the command line.
Why different configurations for web sapi and for CLI? Because you might have different requirements; often devs will run long command line scripts and don't want the web sapi timeout applied, similarly with memory settings; and max file/post size ini settings are meaningless for CLI, so why bother having them in the cli ini file when they're only needed for the web?
php -i
gives you the same info you got using phpinfo()
but:
Edit: don't digged the sources, but I can bet both uses the same code to extract their info .. in other words php -i is "calling phpinfo()
" in a console-aware way and context
Depending on your server distribution, there may be separate php.ini files for the command line and web server.
Source:
Pro PHP Patterns, Frameworks, Testing and More By Kevin McArthur