I think that a function called phpinfo is a function displaying environment of PHP, but results of phpinfo which I carried out from a command-line as a result of phpinfo that I displayed it on a Web server are different. Why will these be different? I want to become the same result.
PHP called from your webserver can be configured very differently from your command line PHP.
It depends on your webserver setup. If you have your webserver simply call your /usr/local/bin/php
(or similar) binary then you will have mostly identical output(except without any of the CGI environment variables such as HTTP_HOST, REFERRER, etc.
On the other hand, if you are using mod_php
with apache or php through fast-cgi, your phpinfo will return different values, as mod_php
is a separately compiled module for php. It does not call the standard php
command that you access through the command line.
Another possible reason for the differences are that your webserver is using a different php.ini
file. The php.ini
file tells php what extensions to load, and basically can set most of the parameters that are found on a phpinfo()
page.
It will be hard to make these the same result, unless you can configure your webserver to not send any HTTP headers through to your PHP script, and make sure your php setup for your webserver matches(or directly calls) your command line php build. You can ensure that the php.ini files are the same-- phpinfo()
contains the name of the currently loaded configuration file.
I don't think you'll be able to get them identical regardless, and I don't understand why you want the output to be identical. If you want the settings to be similar, you will want to edit the respective php.ini
file to change the settings to what you would like them to be. Also, if you don't have access to the php.ini
file, you can use the php function ini_set()
to set some configuration varibles at run time.