Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP cast from string to int error

Tags:

php

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?

intval() works just fine but I cannot use int() for some reason.

like image 357
David Avatar asked Aug 16 '26 06:08

David


1 Answers

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

$b = (int) $a;

Or:

settype($a, 'int');
like image 190
Delan Azabani Avatar answered Aug 18 '26 19:08

Delan Azabani