note 71361 deleted from function.phpversion by nlopess
| From: | nlopess@php.net | Date: | Sun, 18 Mar 2007 12:42:42 +0000 |
| Subject: | note 71361 deleted from function.phpversion by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124570@lists.php.net to get a copy of this message | ||
Note Submitter: georgemoney dot php at gmail dot com
----
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
}
}
}
?>