tags:

views:

50

answers:

3

Hi when trying to cast from a string to int using int() i get the following error:

Call to undefined function int()

Why would this be?

inval() works just fine but i cannot use int() for some reason

A: 

Have you tried

$intVar = (int)$var;

If PHP is telling you that int() isn't a function, then it probably isn't.

Michael Robinson
+3  A: 

There is no int function; you must use proper typecasting syntax for this:

$b = (int) $a;
Delan Azabani
A: 
function int($string) {
   return (int) $string;
}
Alexander.Plutov