note 72655 deleted from function.is-numeric by didou

From: Date: Sun, 28 Jan 2007 18:28:26 +0000
Subject: note 72655 deleted from function.is-numeric by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122299@lists.php.net to get a copy of this message
Note Submitter: ssadler at mashi dot org Reason: bad code ---- If you want to check the validity of an integer from user input, use this: <?php function get_int(&$i,$set=false) { if ($set) $j =& $i; else $j = $i; return ((string) $j === (string) $j = (int) $j); } ?> This is the most efficient way that I have found, it will return true on any string or integer variable containing a 32bit signed int. If $set is true, it will also cast the input to int type.

« previous php.notes (#122299) next »