note 15694 deleted from function.is-int by jimw

From: Date: Thu, 20 Dec 2001 23:34:58 +0000
Subject: note 15694 deleted from function.is-int by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23580@lists.php.net to get a copy of this message
A much better way of addressing the ID problem is as follows: function valid_id($id) { if (strval(intval($id)) === $id) return true; else return false; } This will not allow entries like "12." or a blank entry. It will allow positive or negative integers. You can disallow negative integers by adding " && $id >= 0" to the if expression.

« previous php.notes (#23580) next »