Home  >  Article  >  Backend Development  >  Detailed explanation of four methods to check the PHP version

Detailed explanation of four methods to check the PHP version

眼眸间的深情
眼眸间的深情Original
2021-07-19 17:18:4322074browse

Recently, I found that many novice friends are searching for "how to check the PHP version". It happened to rain recently. I took this opportunity to share the practical process of this method with the novice friends. I It has also been a step-by-step journey from the novice road to the professional project now, so I naturally empathize with how difficult the novice road is, so let us work together to work together on this road of PHP development and move forward together! Without further ado, here’s the method:

First of all, let’s take a look at the first way to check the PHP version:

PHP uses the function phpinfo():

<?php
   echo phpinfo();
?>

Screenshot of personal actual operation after running the code:

Detailed explanation of four methods to check the PHP version

As shown in the picture above, you can see our code where the arrow points. Does the PHP version running feel very simple? In fact, PHP is easy to learn, so be bold and learn it!

Then let’s look at the second method of checking the PHP version used by the project to run:

Command line input php –v:

As shown below, use the Win R key to open the command box:

Detailed explanation of four methods to check the PHP version

Then enter cmd:

Detailed explanation of four methods to check the PHP version

Then press the "Enter" key to enter the interface as shown below:

Detailed explanation of four methods to check the PHP versionDetailed explanation of four methods to check the PHP version

Knocking on the blackboard, please pay special attention to the following, if not If you pay attention to these options, your cmd command box will not be online and will stop working!

Note: PHP environment variables need to be configured

The steps to configure PHP environment variables are as follows:

① Right-click the "Computer" icon, the following page will appear:

Detailed explanation of four methods to check the PHP version

## ② Click "Advanced System Settings", the following page will appear :

Detailed explanation of four methods to check the PHP version

##③Click "Environment Variables" and the following page will appear:

Detailed explanation of four methods to check the PHP version

④Find the Path line and copy the PHP directory into the small box (note: the added Path and the previous default Path need to be separated by English; ): My PHPPath: F:\zero_wampserver\wamp\bin\php\php5.5.12

(Just find the directory where php.exe is located)

⑤ Click "OK" to complete the environment variable configuration, as shown in the figure below.

Detailed explanation of four methods to check the PHP versionThe configuration is complete, then you can easily get the PHP version as I did in the picture.

Let’s look at the third way to check the PHP version:

Use the predefined constant PHP_VERSION query:

<?php
   echo PHP_VERSION;
?>
Rendering display after running the code:

Detailed explanation of four methods to check the PHP versionFinally, let’s take a look at the fourth method of checking the PHP version:

Use the phpversion() function to query:

<?php
   echo phpversion();
?>
The rendering after running the code:

Detailed explanation of four methods to check the PHP versionOkay, I have already introduced the method of checking the PHP version. I believe that the friends who are watching have learned how to check the version information of PHP running in their own code. Finally, I have a sentence to share with you, and I hope everyone can encourage you together:

PHP is actually very simple, but we must keep moving forward on the road of learning, constantly check PHP documents, watch some PHP tutorial videos, communicate with more friends, learn together, and work hard together, only In this way, we can continue to move forward in the PHP industry and keep ourselves from being eliminated. Come on! A group of friends who love PHP!

The above is the detailed content of Detailed explanation of four methods to check the PHP version. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn