intval($string);
$num = intval("10");
$num = floatval("10.1");
s = "123";
echo intval(s); // 123
s = "hello";
echo intval(s); //0
$num = "3.14";
$int = (int)$num;//string to int
$float = (float)$num;//string to float
method_1:
intval($string);//for string to integer
floatval($string); //for string to float
method_2:
$int = (int)$string;//string to int
$float = (float)$string;//string to float
$num = "3.14";
$int = (int)$num;
// intval() function to convert
// string into integer
echo intval($num), "
";
$myintvariable = intval($myvariable);
$str = "10";
$num = (int)$str;
intval("15");
// Type cast using int
echo (int)$num, "
";
intval ( mixed $var [, int $base = 10 ] ) : int