How to check the installed php version
How to check the php version: 1. Use the "echo phpinfo();" statement to view the PHP version information in the output result; 2. Use the "echo phpversion();" statement to output directly PHP version number; 3. Use the "echo PHP_VERSION;" statement.
The operating environment of this tutorial: windows7 system, PHP5.5.12 version, DELL G3 computer
View the installed php Version method
1. Use the phpinfo()
function to get the PHP version number
Speaking of getting the PHP version number , the first thing that comes to mind is to use the phpinfo() function, which can return information about PHP configuration.
The output information includes: PHP version, server information and environment variables, PHP environment variables, operating system version information, path and environment variable configuration, HTTP headers, and copyright declaration, etc.
We only need to directly output the phpinfo() function:
<?php echo phpinfo(); ?>
Output result:
2. Use phpversion()
Function to get the PHP version number
The phpinfo() function returns too much content. If you just want to get the PHP version number, just use the phpversion() function directly.
<?php header("content-type:text/html;charset=utf-8"); echo "当前PHP的版本为:".phpversion(); ?>
Output result:
3. Use predefined constantsPHP_VERSION
The PHP_VERSION constant can return the current PHP version number in the form of a string. The specific format is "major version number.sub version number.stage version number[extended information]
".
<?php header("content-type:text/html;charset=utf-8"); echo "当前PHP的版本为:".PHP_VERSION; ?>
Output result:
It can be seen that the output result of the predefined constant PHP_VERSION
is the same as phpversion()
The same function.
In addition to the PHP_VERSION constant that can return PHP version information, the predefined constants PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PHP_VERSION_ID, and PHP_EXTRA_VERSION can also return part of the PHP version information.
PHP_MAJOR_VERSION (int)
The major version number of the current PHP version, in the form of an integer (for example: "5.2.7-extra" version is int(5)) .PHP_MINOR_VERSION (int)
The sub-version number of the current PHP version, in the form of an integer (for example: "5.2.7-extra" version is int(2)).PHP_RELEASE_VERSION (int)
The stage version number of the current PHP version, in integer form (for example: "5.2.7-extra" version is int(7)).PHP_VERSION_ID (int)
The integer of the current PHP version, used for version comparison (for example: "5.2.7-extra" version is int(50207)).PHP_EXTRA_VERSION (string)
The "extended information" information of the current PHP version, in the form of a string (for example: "5.2.7-extra" version is '-extra') . Typically used by distribution vendors to indicate the version of a package.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to check the installed php version. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



As a PHP learner and developer, how can I not understand its history? The following PHP Chinese website will lead PHP enthusiasts to review the various historical versions of PHP.

Pagoda Panel is a powerful and easy-to-use server management panel that can help users easily manage websites, databases, FTP and other services. In the process of using the Pagoda Panel, sometimes you need to switch the PHP version to adapt to different website needs. This article will provide you with a simple guide for PHP version switching, and provide specific code examples to help readers quickly complete the PHP version switching operation. First, we need to log in to the Pagoda panel and enter the website settings page. Find the "Website" option in the left navigation bar and click

BTPanel is a powerful and easy-to-use server management panel that can help users easily manage servers, websites, databases and other services. As a website developer or administrator, it is very important to master the skills of switching PHP versions in the Pagoda panel. In this article, we will share how to operate and switch PHP versions in the Pagoda panel, and provide specific code examples to help readers better master this skill. 1. Log in to the Pagoda panel. First, enter the server IP address or domain name in the browser, and add the Pagoda

The meaning and importance of PHP version NTS PHP (Hypertext Preprocessor) is a widely used open source server-side scripting language that is used to develop dynamic web pages. PHP versions include NTS (Non-ThreadSafe) and TS (ThreadSafe). In this article, we will focus on the meaning and importance of NTS versions and provide some concrete code examples. The NTS version refers to the non-thread-safe version of PHP, which was originally designed to

When developing a website or application using PHP, version upgrades are a necessary task because each version brings new features and fixes known issues. However, PHP version upgrades can also introduce new bugs because the new version may no longer support the functionality or syntax of the older version. In this article, we will introduce how to deal with errors caused by PHP version upgrade to ensure the normal operation of the application. 1. Back up the application and server. Before upgrading the PHP version, you must back up the application and server. The backup application can be

Eclipse is a widely used integrated development environment (IDE) that can be used to develop projects in various programming languages. When using Eclipse to develop PHP projects, it is sometimes necessary to update the PHP version to adapt to new features or fix bugs. This article will explain how to update the PHP version in Eclipse and provide specific code examples. 1. Preparations for updating the PHP version Before updating the PHP version, we need to ensure that Eclipse and the PHP development environment have been installed. in addition,

Impact of PHP function version updates: Impact of new features: New features are introduced to facilitate the development of complex tasks. Fix the impact of the bug: Improve function behavior and improve code stability. Impact of behavior change: Most disruptive, requiring updates to code that uses the function. Best practices: Test updates in a test environment, check interactive code, and update affected dependencies.

New features of PHP7 version and their impact on mini program development. With the continuous development of technology, the Internet industry is also changing with each passing day. In recent years, mini programs have become a hot topic in mobile application development. At the same time, the release of PHP7 version has also become the focus of developers' attention. This article will explore the new features of the PHP7 version and analyze its impact on the development of small programs. 1. New features of PHP7 version As a major update of the PHP language, PHP7 version brings many new features and performance improvements. Here are a few important new features: Sex
