Solution: First open the "/etc/profile" file, execute the "export PATH="/usr/local/php/bin:$PATH"" command and add an environment variable in the last line; then execute " source /etc/profile" command to save and exit.
The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, PHP version 7.1, DELL G3 computer
php -v shows that the version is inconsistent with the version printed by phpinfo()
First check how many php.ini there are on Linux. It turns out that there are two:
I roughly guess that the php configuration file loaded by php cli is inconsistent with the configuration file loaded by phpinfo(). Use the command to view the php.ini loaded by cli. Which one is it:
php -i | grep php.ini
The result is:
Then check the result printed by phpinfo():
It is found that the loaded php.ini configuration file is indeed inconsistent, then search the php/bin directory, Edit the /etc/profile file Add an environment variable in the last line:
export PATH="/usr/local/php/bin:$PATH"
Finally save And exit and execute the following command:
source /etc/profile
It is caused by the inconsistency between the php configuration file loaded by cli and the php configuration file loaded by the web server. Just unify their loading configuration files.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of What should I do if the versions viewed by php -v and phpinfo are inconsistent?. For more information, please follow other related articles on the PHP Chinese website!