Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: phpversion - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

putenv" width="11" height="7"/> <phpinfo
Last updated: Thu, 31 May 2007

view this page in

phpversion

(PHP 4, PHP 5)

phpversion — 現在の PHP バージョンを取得する

説明

string phpversion ( [string $extension] )

現在動作中の PHP パーサあるいは拡張モジュールのバージョンを表す文字列を返します。

パラメータ

extension

オプションで指定する拡張モジュール名。

返り値

オプションの extension パラメータが指定されている場合、phpversion() はその拡張モジュールのバージョンを返します。 関連するバージョン情報が存在しない場合、 あるいは拡張モジュールが有効でない場合は FALSE を返します。

例 1807. phpversion() の例

<?php
// たとえば 'Current PHP version: 4.1.1' などと表示します
echo 'Current PHP version: ' . phpversion();

// たとえば '2.0' などと表示します。拡張モジュールが有効でない場合は何も表示しません
echo phpversion('tidy');
?>

注意

注意: この情報は、定義済みの定数 PHP_VERSION でも取得可能です。

参考

version_compare()
phpinfo()
phpcredits()
php_logo_guid()
zend_version()



putenv" width="11" height="7"/> <phpinfo
Last updated: Thu, 31 May 2007
 
add a note add a note User Contributed Notes
phpversion
itsec
22-Aug-2007 04:30
in reply to natio at phpfox dot com:

PHP 4 in GNU/Linux (Debian Etch) has this version: "4.3.10-21"

You could wrap using floatval:

floatval(PHP_VERSION) but this could probably change in a next php version so floatval would return another value like 4, 0 or FALSE.

I would not recommend to numerically compare version numbers!
natio at phpfox dot com
15-Aug-2007 11:44
Another method of checking a version (e.g 5.2.0 is 520) could be:

<?php
if ( (str_replace('.', '', PHP_VERSION)) < 520 )
{
    die (
'This script needs PHP 5.2.0 or above!' );
}
?>
smifffy at smith-net dot org dot uk
10-Apr-2007 03:09
Just a simple version checker

replace 520 with the version you want to limit to without the periods

e.g 4.3.1 is 431

<?php
$ver
= explode( '.', PHP_VERSION );

$ver_num = $ver[0] . $ver[1] . $ver[2];

if (
$ver_num < 520 )
{
    die (
'This script needs PHP 5.2.0 or above!' );
}
?>

putenv" width="11" height="7"/> <phpinfo
Last updated: Thu, 31 May 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites