1

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.

1
  • php is a loosely typed language, so better get used to it from now :D Commented Mar 22, 2012 at 6:44

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You can check it using is_numeric(),then throw an exeption

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.