PHP weak type (2)
3.intval() function
The intval() function is used to get the integer part of the variable, in the following part of the code:
<?php
$uid = $_GET['uid'];
if ($uid == "1")
{
$uid = intval($uid);
$query = "SELECT * FROM 'users' WHERE uid=$uid;";
}
$result = mysql_query($query)
print_r(mysql_fetch_row($result));
When uid=0.9999999999999999 is a long floating point number, the code logic will enter the if statement to query the user information with uid=0.
Output result:
4. Array comparison:
In_array() and array_seach() functions, if the $strict parameter is not set to true, loose comparison will be used. (The default setting is false)
<?php
$array = [0,1,2,'3'];
var_dump(in_array('abc', $array)); // true
var_dump(array_search('abc', $array)); // 下标为0
var_dump(in_array('1abc', $array)); // true
var_dump(array_search('1abc', $array));// 下标为1