note 33179 added to function.is-int

From: Date: Wed, 18 Jun 2003 10:44:06 +0000
Subject: note 33179 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-50571@lists.php.net to get a copy of this message
Or you could just use is_numeric() I have a file called input.php which I run at the beginning of all my scripts which makes sure all my input numbers are converted to integers automatically. if ($_GET) { foreach ($_GET as $k => $v) { $_GET[$k] = trim (stripslashes ($v)); if (is_numeric ($v)) { $_GET[$k] = intval ($v); } } } if ($_POST) { foreach ($_POST as $k => $v) { $_POST[$k] = trim (stripslashes ($v)); if (is_numeric ($v)) { $_POST[$k] = intval ($v); } } } if ($_COOKIE) { foreach ($_COOKIE as $k => $v) { $_COOKIE[$k] = trim (stripslashes ($v)); if (is_numeric ($v)) { $_COOKIE[$k] = intval ($v); } } } ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33179 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33179&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33179&report=yes

« previous php.notes (#50571) next »