Home > Article > Backend Development > How to view locally installed php
When developing PHP web pages, we need to configure and install PHP in the local environment to realize the functions of writing, debugging and testing PHP code. However, when we need to upgrade the PHP version or add a new PHP extension, we need to query the locally installed PHP version to determine the existing configuration. This article explains how to view your locally installed PHP.
1. Use the command line to view the locally installed PHP version
The command line is one of our most commonly used operating methods, and the command line is provided under Windows, Linux and macOS platforms. to view the locally installed PHP version.
1. Check the locally installed PHP version under the Windows platform
Under the Windows platform, we can check the local PHP version through the command line tool command that comes with Windows. Enter the following command in the command line window:
php -v
After pressing Enter, we can see the local PHP version, compiler information and dependent library information.
2. View the locally installed PHP version under the Linux platform
Under the Linux platform, we can also use the command line to view the locally installed PHP version. You can use the following command:
php -v
Just like on the Windows platform, we can also enter this command in the command line window and press Enter to view the locally installed PHP version.
3. View the locally installed PHP version under the macOS platform
Under the macOS platform, we can also view the locally installed PHP version through the command line. The steps are similar to those on Windows and Linux platforms. You only need to enter the following command in the terminal window:
php -v
2. Use the phpinfo() function to view the locally installed PHP version
phpinfo( ) function is one of the most commonly used functions by PHP programmers because it can be used to display the configuration information of the current PHP system. We can use this function to view the locally installed PHP version. The method is as follows:
1. Build a PHP environment locally and save the following content as a PHP file, for example: test.php.
<?php phpinfo(); ?>
2. Open the file in the browser, for example: http://localhost/test.php.
3. In the page that opens, you can find the PHP version information, as well as other configuration information, such as compilation parameters and installed extensions. This method can provide more detailed and comprehensive PHP configuration information.
3. Use Windows environment variables to view the locally installed PHP version
Under the Windows platform, we can also view the installed PHP version through environment variables. The method is as follows:
1. Right-click "Computer" or "This PC" on the desktop and select "Properties".
2. Select "Advanced System Settings".
3. Select "Environment Variables".
4. In the system variables, find the PATH variable and click "Edit".
5. In the Edit Environment Variables window, we can see all the environment variables that have been installed in the system, including the installation path information of PHP. Find the content containing the "php.exe" file path, and you can view the PHP version number of your machine.
In this way, you can see which directory PHP.exe is located in, and then find the version number information of PHP.
Conclusion
When we develop PHP, we need to frequently query the local PHP version and extension information to facilitate us to determine the consistency between the development environment and the runtime environment. This article introduces three methods of viewing the local PHP version, each with its own scope of application and considerations. We can use these methods to operate in different development and management scenarios to easily complete the tasks we need.
The above is the detailed content of How to view locally installed php. For more information, please follow other related articles on the PHP Chinese website!