Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人可以向我解释这个..:
$bob = $_POST['foo'] ;
is_int($bob)失败但is_numeric($bob)没关系。
is_int($bob)
is_numeric($bob)
所以我知道我不能直接在 $_POST 上使用 is_int 但在这里我之前将 post 值转移到另一个变量中..
请问怎么了?!
$_POSTvalues 是字符串,无论它们是否包含数值。只是将它们转移到不同的变量并不会改变这一点。
$_POST
您必须对变量进行类型转换:
$bob = (int) $_POST['foo'];
0但请注意,在这种情况下会强制转换为非整数值。
0