开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜