This article will introduce to you how to add and switch PHP versions. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
1. Add PHP version
1. WampServer (32-bit) has been installed. My PHP directory is A:\WampServer\wamp\bin \php\php5.4.3, that is, the default installed PHP version is 5.4.3.
Some projects require different PHP versions, so you need to add multiple PHP versions in the wamp\bin\php directory.
I have successfully installed version 7.2.8 of PHP before. The first time I installed 64-bit PHP, it was not successful. After deleting and reinstalling 32-bit PHP, it was successful.
Now when I am working on a project, I encounter an error message "count():Parameter must be an array or an object that implements Countable". It is necessary to lower the PHP version, so now I will install the PHP7.1 version.
Here, these two tutorials for adding PHP version are enough: "Add support for multiple versions of PHP (PHP5.3, PHP5.4, PHP5.5) under WAMPSERVER. 》 and "How to upgrade php version---Practice of upgrading php7.1.5 wamp from php5.5.12".
2. Download the required PHP version "*** x86 Thread Safe" from https://windows.php.net/download/. For example, I downloaded the Zip package of PHP7.1.21 version and put it in Go to the PHP directory, such as my directory A:\WampServer\wamp\bin\php, unzip and rename the folder "php7.1.21", which is the "PHP version number".
If you want to know about different download versions, you can read "How to choose the version of php under windows?" 》.
3. Copy the php.ini, phpForApache.ini, and wampserver.conf files in the existing version of php folder (such as the PHP5.4.3 folder) to the php7.1.21 folder.
4. Modify the two files php.ini and phpForApache.ini, find all php5.4.3 in the two files and replace them with php7.1.21.
5. Modify the wampserver.conf file and refer to step 6 of "How to upgrade php version --- Upgrade php7.1.5 wamp practice from php5.5.12".
I found the "apache2.2.22" folder from the wamp\bin\apache directory, so my apache version is 2.2X, then the modifications in the wampserver.conf file are as follows:
$phpConf['apache']['2.2']['LoadModuleName'] = 'php7_module'; $phpConf['apache']['2.2']['LoadModuleFile'] = 'php7apache2_2.dll';
6. Delete the php.ini file in the wamp\bin\apache\apache2.2.22\bin directory.
7. In the wamp\bin\apache\apache2.2.22\conf directory, find the httpd.conf file, search for LoadModule, and change it to
LoadModule php7_module "A:/WampServer/wamp/bin/php/php7.1.21/php7apache2_2.dll"
8. In wamp\bin\ In the php\php7.1.21 folder, create a new folder and name it "zend_ext".
Download the corresponding dynamic link library from https://xdebug.org/download.php to the zend_ext folder. My version is 7.1, Thread Safe, 32-bit. The name of this dynamic link library is "php_xdebug-2.7.0alpha1-7.1-vc14.dll".
9. In the wamp\bin\php\php7.1.21 folder, find the php.ini file and modify it as follows:
; XDEBUG Extension zend_extension = "A:/WampServer/wamp/bin/php/php7.1.21/zend_ext/php_xdebug-2.7.0alpha1-7.1-vc14.dll"
10. Finally , comment out this sentence
;extension=php_mysql.dll
11. Restart WampServer in the php.ini file.
Left click on the WampServer icon, select "PHP", and curiously click on the "php.ini" file (this file is actually in the wamp\bin\apache\apache2.2.22\bin folder, previous step 6 It was deleted once, and it should be automatically generated again).
Out of curiosity, I changed the "php version number" in the "php.ini" file to "php7.1.21", and the dynamic link library was also changed according to step 9.
extension_dir = "A:/WampServer/wamp/bin/php/php7.1.21/ext/"
; XDEBUG Extension zend_extension = "A:/WampServer/wamp/bin/php/php7.1.21/zend_ext/php_xdebug-2.7.0alpha1-7.1-vc14.dll"
12. After installing it, click to open WampServer a few times (I didn’t see the php7.1.21 version at first, so I clicked a few more times), PHP→Version “7.1.21” appears, so far Added php version successfully.
But the "√" in front of PHP→Version is still in front of "7.2.8", so I entered
php -v
in the command prompt window cmd and found that the currently used PHP version has not changed. It is still "php7.2.8", let's switch the PHP version.
Recommended learning: php video tutorial
2. Switch PHP version
Just set the PHP environment variables under Windows, refer to the tutorial "Under Windows Set PHP environment variables".
1. Under Win10, right-click "This PC" → "Properties" → "Advanced System Settings" → "Environment Variables", find "Path" in "System Variables", and double-click to edit.
#2. Find the path to php, change the last path "php7.2.8" to the version you want, here change it to "wamp\bin\php\php7. 1.21".
3、在命令提示符窗口cmd输入
php -v
可以看到,php的版本已经切换成功了。
The above is the detailed content of How to increase and switch PHP version. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft