Is someone can explain me this..:

$bob = $_POST['foo'] ;

is_int($bob) FAIL but is_numeric($bob) is OK .

So i know i cannot use is_int directly on $_POST but here i transfert the post value in another variable before..

Whats wrong please ?!

有帮助吗?

解决方案

$_POST values are strings, no matter whether they contain a numeric value or not. Just transferring them to a different variable doesn't change that.

You'd have to typecast the variable:

$bob = (int) $_POST['foo'];

but note that non-integer values are cast to 0 in this case.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top