note 58011 added to function.phpversion
| From: | chris dot nospam at nospam dot telestatic dot net | Date: | Fri, 21 Oct 2005 15:09:11 +0000 |
| Subject: | note 58011 added to function.phpversion | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97355@lists.php.net to get a copy of this message | ||
In 5.0.4, phpversion() seeminly cannot be manipulated by trim(), despite returning a string.
If you *do* want to compare PHP versions numerically, then here's the easiest/quickest way I
could think of to make an integer value out of the returned phpversion() string value:
<?php
$phpVersion=explode(".",phpversion());
$phpVersion=substr($phpVersion[0],0,1);
$phpVersion.=substr($phpVersion[1],0,1);
$phpVersion.=substr($phpVersion[2],0,1);
if ($phpVersion>="420") {
//... Do stuff here ...
}
?>
(My real example would have had all three substr() calls on one line, but it makes the string too
long for the PHP comment thing)
The above removes the need for any regexp calls, which I feel is neater.
----
Manual Page -- http://www.php.net/manual/en/function.phpversion.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58011
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58011&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58011&report=yes
Search -- http://master.php.net/manage/user-notes.php