In PHP, it seems like every object can be converted to an integer, just by calling intval($object), but this is not what I want. What I want is, to check if the object would be valid to be converted into an integer for what a human thinks it is.
I.e., valid objects would be
1212.0"12""12.0"
And not valid would be
MyFooInstance()"some string""12.0.0""0 12.0"
etc.
In python, I could simply to the following:
try:
int(var)
except (TypeError, ValueError):
return False
return True
How can I achive this in PHP?
Use is_numeric.
(From the page)