note 58011 deleted from function.phpversion by nlopess

From: Date: Fri, 21 Oct 2005 17:49:04 +0000
Subject: note 58011 deleted from function.phpversion by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-97374@lists.php.net to get a copy of this message
Note Submitter: chris dot nospam at nospam dot telestatic dot net ---- 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.

« previous php.notes (#97374) next »