php v The solution to the wrong version: 1. Search for php.ini on Linux; 2. Use the "#php -i | grep php.ini" command to view the php.ini loaded by cli; 3. , search for the "php/bin" directory and edit the "/etc/profile" file; 4. Add an environment variable to the last line as "export PATH="/usr/local/php/bin:$PATH"".
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
php v What should I do if the version is wrong?
Solve the problem that the version viewed by php -v is inconsistent with the version printed by phpinfo() (LNMP environment)
Use phpinfo to print and find that the version is 7.2.31?
Copyright (c) 1997-2013The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Solution
1. First, check how many php.ini there are on Linux. It turns out that there are two:
[[email protected] ~]#find / -name php.ini /usr/local/php/etc/php.ini/etc/php.ini
It is roughly guessed that the php configuration file loaded by php cli is inconsistent with the configuration file loaded by phpinfo(). Use the command to see which php.ini is loaded by cli:
[[email protected] ~]#php -i | grep php.ini
The result is:
It is found that the loaded php.ini configuration file is indeed inconsistent, then search the php/bin directory and edit the /etc/profile file
[[email protected] /]#vim /etc/profile
Add an environment variable in the last line:
export PATH="/usr/local/php/bin:$PATH"
Finally save and exit and execute the following command to refresh the environment variable:
[[email protected] /]#source /etc/profile
php -v View version
Summary
It is caused by the inconsistency between the php configuration file loaded by cli and the php configuration file loaded by the web server.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if the php v version is wrong?. For more information, please follow other related articles on the PHP Chinese website!