PHP: phpversion - Manual

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

search for in the

putenv phpinfo

Last updated: Sat, 27 Jan 2007

view this page in

# phpversion

(PHP 3, PHP 4, PHP 5)

phpversion -- Gets the current PHP version

## Description

string phpversion ( [string extension] )

Returns a string containing the version of the currently running PHP parser. If the optional `extension` parameter is specified, phpversion() returns the version of that extension, or `FALSE` if there is no version information associated or the extension isn't enabled.

> Замечание: This information is also available in the predefined constant `PHP_VERSION`.

Пример 1. phpversion() example

`<?php
// prints e.g. 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' . phpversion();
// prints e.g. '2.0' or nothing if the extension isn't enabled
echo phpversion('tidy');
?>`

See also version_compare(), phpinfo(), phpcredits(), php_logo_guid(), and zend_version().

add a note User Contributed Notes
phpversion
mauron at maurtopia dot com
09-Feb-2007 03:11
`A faster way to check the version of PHP being used is this code.
<?php
if (strpos(phpversion(), 5) === 0)
$is5 = true;
else
$is5 = false;
?>
For the most part the difference won't matter, but if you're running a site with large amounts of traffic it's worth keeping in mind.`
georgemoney dot php at gmail dot com
23-Nov-2006 07:33
`some nice little functions to tell the php version number
<?php
function phpnum() {
$version = explode('.', phpversion());
return (int) $version[0];
}
function is_php5() { return phpnum() == 5; }
function is_php4() { return phpnum() == 4; }
?>
Here are some examples of why this comes in handy:
<?php
if(is_php5()) {
class MyClass {
public function __construct() {
//foo
}
}
} else {
class MyClass {
function MyClass() {
//foo
}
}
}
?>`
add a note
putenv phpinfo

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST