开发者

PHP : is_nan() returning an error

开发者 https://www.devze.com 2023-04-06 03:23 出处:网络
I am simply trying to validate a value using is_nan(). I have my class named validate() which can do this, but I am little bit trying to optimize my code 开发者_如何转开发using php\'s function.

I am simply trying to validate a value using is_nan(). I have my class named validate() which can do this, but I am little bit trying to optimize my code 开发者_如何转开发using php's function.

So question is simple.I m using this code and in response I m getting this error. How to remove this error?? What I am doing wrong?? Is there any other way to achieve this goal except preg_match()??

$discount = "0nbgjgvbngjxk";

var_dump(is_nan($discount));

Result :

Error : A non well formed numeric value encountered

bool false

Though I am getting the result correct, but how why this error is coming.I m validating for numbers. I m using CodeIgniter, so these errors can be disabled when made live. But I m curious to solve the error.

Thanks.


is_nan takes a float as an argument, but you're passing it a string.

Check out is_numeric which might be closer to what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消