note 63381 rejected from function.phpversion by bjori
| From: | bjori@php.net | Date: | Tue, 21 Mar 2006 19:59:49 +0000 |
| Subject: | note 63381 rejected from function.phpversion by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106173@lists.php.net to get a copy of this message | ||
Note Submitter: nino at clan-csc dot com
----
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
?>