PHP cast from string to int error
Hi when t开发者_开发知识库rying to cast from a string to int using int()
I get the following error:
Call to undefined function int()
Why would this be?
intval()
works just fine but I cannot use int()
for some reason.
There is no int
function; you must use proper typecasting syntax for this:
$b = (int) $a;
Or:
settype($a, 'int');
function int($string) {
return (int) $string;
}
Have you tried
$intVar = (int)$var;
If PHP is telling you that int() isn't a function, then it probably isn't.
精彩评论