Reply to comment

Why comparing?

And why should I compare with boolean? To get another boolean?

And if you are casting "x" to int, you are probably doing something wrong.

There are ways to test if a string is numeric. For me, test a variable to know if it's numeric before casting is smarter than casting to NaN, and after that, compare value with NaN.

PHP converts values to keep simple comparisions like:
"150" == 150

If you don't know what are you doing, I suggest you study a little bit about the language, or use always ===.

Simple like this.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options