note 68397 deleted from language.types.string by nlopess

From: Date: Sun, 13 Aug 2006 19:45:36 +0000
Subject: note 68397 deleted from language.types.string by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115873@lists.php.net to get a copy of this message
Note Submitter: www.regextester.com ---- The simplest way to convert a string value to a number is to use $string+0 $string='a'; if ($string+0===0) echo 'true'; if $string is not a valid number it will return "0" (which is a number) The most useful use of this trick is to make sure you are using integer in sql queries like $query='DELETE FROM table WHERE id='.($_GET['id']+0); You could be pretty sure someone will not hack your script by SQL injection.

« previous php.notes (#115873) next »