Home  >  Article  >  Backend Development  >  How to query the installed php version information in linux

How to query the installed php version information in linux

PHPz
PHPzOriginal
2023-04-26 10:28:552182browse

Linux is a widely used operating system that is widely used in web servers, desktop systems and embedded systems. Since the Linux operating system is based on open source technology, it is often used as a server operating system, while PHP is a widely used programming language, especially in web development. In Linux operating systems, installing PHP is a very common operation because it is a necessary part of web services. This article will introduce how to query the installed PHP version information in the Linux operating system.

1. Using the command line

In the Linux operating system, there is a powerful tool called the "command line" that you can use to perform various tasks, including querying the installed PHP Version Information. In the command line, you can use the following command to query the installed PHP version information.

php -v
php -version

These commands will print the PHP version information you installed, including PHP version and compiler version. Typically, the information will resemble the following:

PHP 7.0.33 (cli) (built: Oct 15 2021 15:41:34) (NTS)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

In the above example, we installed PHP version 7.0.33. If you have a different version of PHP installed, the information printed will correspond to your installed version.

2. Use phpinfo() in web pages

The phpinfo() function is a very useful function in PHP. It can display all information about the current PHP environment, including PHP version and system information. , configuration information, installed extensions, etc. You can query the installed PHP version information by using the Phpinfo() function in your web browser through the following steps:

1. Open your web server configuration file in the Linux server and find the php.ini file.

2. Find the disable_functions parameter in the php.ini file and make sure that phpinfo is not in the parameter list. This will disable the running of the phpinfo() function.

3. Create a phpinfo.php file and add the following code in it:

phpinfo();
?>

4. Place the phpinfo.php file in the public_html directory of your web server root directory.

5. Enter your web server address and the name of the phpinfo.php file in your web browser (for example: http://localhost/phpinfo.php).

6. Open the phpinfo.php file in your web browser. All information about the current PHP environment, including PHP version information, will be displayed.

In the above steps, we created a phpinfo.php file and placed it in the public_html directory in the root directory of the web server. Then, we enter the web server address and phpinfo.php file name into the web browser. This will display all information about the current PHP environment, including installed PHP version information.

Summary

In the Linux operating system, querying the installed PHP version information is a very common operation because it is a necessary part of the Web service. In this article, we introduced two different ways to query installed PHP version information: using the "php -v" or "php -version" command on the command line, and using the phpinfo() function in a web browser. Either method can help you query the installed PHP version information in the Linux operating system.

The above is the detailed content of How to query the installed php version information in linux. 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