Hi friends why people are defining data type in php as below,
$id 开发者_StackOverflow= (int) $_GET['id'];
To make sure the variable really contains a valid number. For example, empty string will be converted to 0, 'abc' will be converted to 0, etc.
This assigns the value of the URL parameter "id"
(converted to an integer) to the variable $id
. The parameters in the URL are of course strings, therefore if you pass an integer this way you first should cast it to the int datatype.
Because that way you know what you are manipulating so there is no surprise.
精彩评论