There are some use cases where we require to find out which PHP versions is working on a web server.
If you plan to build a new web application and might want to update your PHP application, you may need to check the particular PHP version before getting started with the installation.
In this tutorial, i am going to share with you a few useful methods through which you can easily check which PHP version your server is working on.
PHP has been around since a very long time, since its inception it has brought us lots of version updates in the below chart you can see the PHP version history.
This method requires SSH access to the webserver, and you can find out the PHP version using the following command.
You can append either
php --version # or php -v
# output PHP 7.3.11 (cli) (built: Feb 29 2020 02:50:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
The above commands will give you the same output on your terminal screen, so currently, we have installed PHP 7.3.11 version.
What if you are a web server is using exquisite versions of PHP. In this case, you can run the `php` command from the terminal shell, but it will display only the default PHP CLI version. It might be the different version of PHP is being used by the web application.
The easiest method is to check the PHP version is the phpinfo() method. This function displays heaps of information about the PHP server, such as PDO, calendar, installed extensions, environment, compilation options, PHP version, web server information, and many more.
Create a file by the name of domain.com/check-php-version.php, and the place the following code in this file:
<?php phpinfo(); ?>
Then type the following URL on the browser’s address bar and press enter.
Then the full PHP configuration will be displayed on your browser’s screen along with the PHP version.
If you specifically want to check the PHP version and don’t want to expose the full php details, then you can use the following php method.
<?php echo 'Current PHP version is: ' . phpversion(); ?>
Finding out the PHP server details is not that difficult task. In this tutorial, I have shared with your the simplest methods to verify the PHP versions your server is using.
I hope you would love this tutorial and share with others as well.
If you want to learn how to get the current route's name, component pathname or…
React show and hide example. In this tutorial, we will show you how to step…
Tabs are one of the best UI elements for displaying multiple contents in a single…
In this tutorial, we will learn how to create a toast notification component in the…
React js counter using the useReducer hook example. In this post, we will learn how…