As a software developer, it is essential to know the version of PHP that is installed on your system.
This information can come in handy when you are developing or deploying a website or web application that requires a specific version of PHP.
In this tutorial, we will discuss the methods to check the version of PHP installed on your system.
Use the phpinfo() Function
The simplest way to check the version of PHP installed on your system is by using the phpinfo() function.
This function provides information about the PHP environment, configuration, and version.
To use this function, create a new PHP file with the following code:
<?php phpinfo(); ?>
Save this file with a .php extension and upload it to your web server.
Then, access the file through a web browser, and you will see a detailed report about the PHP environment, including the version number.
Use the Command Line Interface
You can also check the version of PHP installed on your system using the command line interface (CLI).
To do this, open the terminal or command prompt and run the following command:
php -v
This will display the version of PHP installed on your system, along with other information about the PHP environment.
Check the PHP Configuration File
Another way to check the version of PHP installed on your system is to check the PHP configuration file (php.ini).
This file contains information about the configuration of PHP, including the version number.
The location of this file varies depending on your operating system and web server, but it is usually located in the php directory.
To check the version of PHP in the configuration file, open the php.ini file using a text editor and look for the following line:
This directive allows you to change the base library path. extension_dir = "./" ; On windows: ; extension_dir = "ext" </code>
The version of PHP is listed next to the extension_dir directive.
Conclusion
In conclusion, checking the version of PHP installed on your system is crucial when developing or deploying a website or web application.
Whether you use the phpinfo() function, the command line interface, or check the PHP configuration file, you will be able to quickly and easily determine the version of PHP installed on your system.




