Function/variable to get PHP version from inside PHP (not PHPINFO)

From: Date: Thu, 28 Sep 2000 19:16:47 +0000
Subject: Function/variable to get PHP version from inside PHP (not PHPINFO)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17955@lists.php.net to get a copy of this message
Is there a function/variable available to get the PHP version you are using? Something like: echo $PHP_VERSION; echo PHP_VERSION(); etc. Why, because: I have defined a function called in_array that I've been using with my PHP3 scripts: function in_array($needle,$haystack) { for($i=0;$i<count($haystack) && $haystack[$i] !=$needle;$i++); return ($i!=count($haystack)); } I use this bit of code a lot, but when I'm on a PHP4 server, I get an error saying: Fatal error: Cannot redeclare in_array() in .... I know that's because PHP4 has a function called in_array. So if I could deterime the version at run time, I would be able to wrap my function definition in an IF statement: Something like: /* this is my wanna be code, no idea if it will really work /* if (PHP_VERSION < 4) { function in_array(...) { ... } } So is this doable? What are other people doing? thanks, mark

« previous php.general (#17955) next »