In Java you can try to convert any String value to Integer, but when value is something else, it will throw NumberFormatException. Is there similar functionality in PHP? I checked intval, but it returns values when String value obviously is not convert-able value.
2 Answers
A language throwing an error is not really a useful feature, it's not what you're actually trying to do.
I assume that you simply want to figure out if your string is numeric. For that there's is_numeric or ctype_digit.