Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think that in that case it should return false instead of 0 so (int)$val === false means that the variable is not a number.

Right now I guess that the alternative is using is_numeric and then casting to int if possible.



But the forced cast to integer is always guaranteed to result in an integer. So why would it make more sense to explicitly force cast a variable's type to an integer and get a boolean as the functions return value?

Edit:

> (int)$val === false

Would always be false because comparing two types, an integer and boolean would always be false.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: