note 23386 modified in function.settype by derick

From: Date: Sun, 09 Feb 2003 16:18:54 +0000
Subject: note 23386 modified in function.settype by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-43689@lists.php.net to get a copy of this message
Usually it won't be necessary to use this function, but some times you need to be sure the variables are of some kind. For example, if you send a number to a database query from a variable passed by GET or POST, you may get sure it's a number by doing SetType ($var, 'integer'); so you can avoid security holes if it isn't a number and you don't need to addslashes() it, or for example, if you need to be sure that a number won't have any decimals after rounding it, you may do the same and as it will be an integer, it won't contain decimals. (ed: change to reflect deleted of other notes) --was-- oliver AT mydalon DOT com: Usually it isn't necessary, but some times you need to be sure the variables are of some kind. For example, if you send a number to a database query from a variable passed by GET or POST, you may get sure it's a number by doing SetType ($var, 'integer'); so you can avoid security holes if it isn't a number and you don't need to addslashes() it, or for example, if you need to be sure that a number won't have any decimals after rounding it, you may do the same and as it will be an integer, it won't contain decimals. http://www.php.net/manual/en/function.settype.php

« previous php.notes (#43689) next »