New PHP versions are typically delayed to be implemented by hosting companies on their systems. As a result, how to Check Your PHP Version? there are numerous PHP versions available online at any given time.
Knowing which PHP version your web server is using is crucial if you’re adding new features, setting up a new PHP-based application, or looking for bugs on your website.
You will discover how to verify How To Check Your PHP Version? in this lesson by executing PHP code on your server or by using the command line.
How To Check Your PHP Version
- PHP installed
- Write access to the server’s file system
- Access to the command line
Run PHP Code to Verify PHP Version
Executing a PHP file containing the following code will reveal the PHP version that is currently in use on your website.
<?php
PHP version (); echo "PHP version:"
Upload the file to your website’s document root directory after creating it in a text editor like gedit or Notepad.
Then launch a web browser and enter the complete file address in the address box. To upload a file named phpinfo. Php to the root directory of example.com, for instance, go to:
http://www.example.com/phpinfo.php
The code above just displays the PHP version, as shown in the output below:
How to Check PHP Version? Upload a file containing the phpinfo () function if you need more information about your PHP configuration, such as system information, the build date, server API, configuration file information, etc.
<? php
phpinfo ();
This file displays the PHP version in the top-left corner of the browser window, followed by configuration information:
Upload a file with the following code to get a list of all the loaded PHP extensions and their versions:
<?php
get loaded extensions () as I => $ext, for each
{
echo "$ext". "=> ". phpversion($ext). "br/>";
}
Each extension is displayed separately in the output together with the PHP core version:
Using the Command Line, check the version of PHP (Windows, Linux, and macOS)
Use the command line to look up the installed PHP version if you have access to SSH into the remote server. The local installation of PHP can be verified using this method as well.
1: Enter the PHP command.
php -v
2: Linux, macOS, Windows, and other supported operating systems all support the php -v command. The output includes copyright information as well as the PHP version number and build date.
Correct “PHP is not Recognized” Mistake on Windows
How to Check PHP Version? The php -v command on Windows occasionally returns the message “php is not recognized” because the system does not recognize the PHP path.
Set the PATH environment variable first to fix this issue.
1: Enter the path to your PHP installation in place of [location] in the command below.
establish PATH=%PATH%;[location]
2: The PHP version installed on your Windows machine is now displayed when you use php -v.
Conclusion
The purpose of this post was to describe how to verify How to Check PHP Version? installed on your server or local computer. The command-line interface and running PHP code are two of the techniques discussed in this lesson.