search
HomeBackend DevelopmentPHP ProblemWhat does php version mean?

phpversion is a function in PHP used to obtain the current PHP version. Its usage syntax is "phpversion(string $extension = ?): string".

What does php version mean?

#The operating environment of this article: Windows 7 system, PHP version 7.4, Dell G3 computer.

What does php version mean?

phpversion

(PHP 4, PHP 5, PHP 7, PHP 8)

phpversion — Get the current PHP version

Description

phpversion(string $extension = ?): string

Returns a string containing the currently running PHP interpreter or extended version information.

Parameters

extension

Optional extension.

Return value ¶

If the optional parameter extension is specified, phpversion() will return the version of the extension. If there is no corresponding version information, or the extension is not enabled, false is returned.

Example #1 phpversion() Example

<?php
// prints e.g. &#39;Current PHP version: 4.1.1&#39;
echo &#39;Current PHP version: &#39; . phpversion();
// prints e.g. &#39;2.0&#39; or nothing if the extension isn&#39;t enabled
echo phpversion(&#39;tidy&#39;);
?>
示例 #2 PHP_VERSION_ID 范例和用法
<?php
// PHP_VERSION_ID 自 PHP 5.2.7 起有效,
// 如果我们的版本低于该版本,则用以下代码来模拟 
if (!defined(&#39;PHP_VERSION_ID&#39;)) {
    $version = explode(&#39;.&#39;, PHP_VERSION);
    define(&#39;PHP_VERSION_ID&#39;, ($version[0] * 10000 + $version[1] * 100 + $version[2]));
}
// PHP_VERSION_ID 定义为一个数字,PHP 版本越新,数字越大。
// 它的定义是以下的表达式:
//
// $version_id = $major_version * 10000 + $minor_version * 100 + $release_version;
//
// 现在我们可以通过 PHP_VERSION_ID 来检查 PHP 版本,
// 而不用每次都必须用 version_compare() 来检查 PHP 是否支持某个功能。
//
// 比如,我们在此可以定义一系列 PHP_VERSION_* constants 常量,
// 而在 5.2.7 之前的版本并没有被定义。
if (PHP_VERSION_ID < 50207) {
    define(&#39;PHP_MAJOR_VERSION&#39;,   $version[0]);
    define(&#39;PHP_MINOR_VERSION&#39;,   $version[1]);
    define(&#39;PHP_RELEASE_VERSION&#39;, $version[2]);
    // 等等, ...
}
?>

Comments

Note:

This information also exists in the predefined constant PHP_VERSION. More version information can be obtained using the constants PHP_VERSION_*.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What does php version mean?. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!