note 63381 added to function.phpversion
| From: | nino at clan-csc dot com | Date: | Tue, 21 Mar 2006 19:56:55 +0000 |
| Subject: | note 63381 added to function.phpversion | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-106172@lists.php.net to get a copy of this message | ||
I've found a smart way of using phpversion().
As you may know, objects and classes got ready for using since PHP4.
So, so you may do an check if the PHP version supports or not supports classes.
If do, everything fine. Otherwise, use some other (probably not so good and slower) way to do your
job.
Once I was doing on something which is redistributed.
So, here' s a way I was talking about:
<?
// Note this ain't a whole script, just a part to
// show my idea
include("class.doChange.php");
$templates = new FastTemplate(".");
if(phpversion() >= "4.2.0"){
if(is_array($_SERVER)){
extract($_SERVER, EXTR_PREFIX_SAME, "server");
}
if(is_array($_GET)){
extract($_GET, EXTR_PREFIX_SAME, "get");
}
if(is_array($_POST)){
extract($_POST, EXTR_PREFIX_SAME, "post");
}
if(is_array($_COOKIE)){
extract($_COOKIE, EXTR_PREFIX_SAME, "cookie");
}
if(is_array($_FILES)){
extract($_FILES, EXTR_PREFIX_SAME, "file");
}
if(is_array($_ENV)){
extract($_ENV, EXTR_PREFIX_SAME, "env");
}
if(is_array($_REQUEST)){
extract($_REQUEST, EXTR_PREFIX_SAME, "request");
}
if(is_array($_SESSION)){
extract($_SESSION, EXTR_PREFIX_SAME, "session");
}
}
//and then I started to global stuff...
// which becomes unrelated
?>
----
Server IP: 161.53.30.180
Probable Submitter: 193.198.132.7
----
X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
UPPERCASE_25_50 autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.phpversion.php
Edit -- http://master.php.net/note/edit/63381
Del: integrated -- http://master.php.net/note/delete/63381/integrated
Del: useless -- http://master.php.net/note/delete/63381/useless
Del: bad code -- http://master.php.net/note/delete/63381/bad+code
Del: spam -- http://master.php.net/note/delete/63381/spam
Del: non-english -- http://master.php.net/note/delete/63381/non-english
Del: in docs -- http://master.php.net/note/delete/63381/in+docs
Del: other reasons-- http://master.php.net/note/delete/63381
Reject -- http://master.php.net/note/reject/63381
Search -- http://master.php.net/manage/user-notes.php