note 104810 deleted from function.settype by danbrown

From: Date: Fri, 08 Jul 2011 15:10:04 +0000
Subject: note 104810 deleted from function.settype by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181357@lists.php.net to get a copy of this message
Note Submitter: Sara Smith ---- "Use intval instead of settype for integers. Much more reliable." While 'intval' is more reliable than 'settype', it is still a PHP function. Functions are significantly slower than raw native conversions. If you need an integer, use a typecast: (int)$someval; Typecasting is baked into the core Zend engine, which is as close to the hardware as you can get in PHP. Everyone should consider intval() and settype() as legacy functions that new code should not use since there are better alternatives in most cases with the sole exception of base conversions where base 10 is not being used in the case of intval().

« previous php.notes (#181357) next »