note 71361 added to function.phpversion

From: Date: Fri, 24 Nov 2006 03:33:32 +0000
Subject: note 71361 added to function.phpversion
Groups: php.notes 
Request: Send a blank email to php-notes+get-120039@lists.php.net to get a copy of this message
some nice little functions to tell the php version number <?php function phpnum() { $version = explode('.', phpversion()); return (int) $version[0]; } function is_php5() { return phpnum() == 5; } function is_php4() { return phpnum() == 4; } ?> Here are some examples of why this comes in handy: <?php if(is_php5()) { class MyClass { public function __construct() { //foo } } } else { class MyClass { function MyClass() { //foo } } } ?> ---- Server IP: 216.194.113.175 Probable Submitter: 69.229.231.19 ---- Manual Page -- http://www.php.net/manual/en/function.phpversion.php Edit -- https://master.php.net/note/edit/71361 Del: integrated -- https://master.php.net/note/delete/71361/integrated Del: useless -- https://master.php.net/note/delete/71361/useless Del: bad code -- https://master.php.net/note/delete/71361/bad+code Del: spam -- https://master.php.net/note/delete/71361/spam Del: non-english -- https://master.php.net/note/delete/71361/non-english Del: in docs -- https://master.php.net/note/delete/71361/in+docs Del: other reasons-- https://master.php.net/note/delete/71361 Reject -- https://master.php.net/note/reject/71361 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120039) next »