Possible Duplicates:
Fastest way to convert string to integer in PHP
PHP: Is there any particular difference between intval and (int)?
Is (int)$var
same as intval($var)
?
Apparently they both do the same thing.
Is there any situation in which they would return different results?
(int)
would seem to be a bit faster than intval
, as you don't have the overhead of a function call. intval
also allows you to set an optional base to convert to, which might be useful:
int intval ( mixed $var [, int $base = 10 ] )