- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP is_nan() Function
Definition and Usage
NAN stands for "Not A Number". The is_nan() function checks whether its argument is not a number.
Syntax
is_nan ( float $val ) : bool
Parameters
Sr.No | Parameter & Description |
---|---|
1 | val The value to be verified if infinite or not |
Return Values
PHP is_nan() function returns TRUE if val is "not a number", otherwise it returns FALSE.
PHP Version
This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.
Example
Following example shows that 100 qualifies as NAN
<?php $val=100; $ret=is_nan($val); var_dump($val, $ret) ?>
Output
This will produce following result −
int(100) bool(false)
Example
Value of log(0) is infinity. Following example verifies if it is NAN −
<?php $val=log(0); $ret=is_nan($val); var_dump($val, $ret); ?>
Output
This will produce following result −
float(-INF) bool(false)
Example
Since cos(x) is between -1 and 1, acos() for parameter outside this range is NAN −.
<?php $val=acos(5); $ret=is_nan($val); var_dump($val, $ret); ?>
Output
This will produce following result −
float(NAN) bool(true)
Example
Similarly sqrt(-1) produces NAN and hence is_nan() function returns true −
<?php $val=sqrt(-1); $ret=is_nan($val); var_dump($val, $ret); ?>
Output
This will produce following result −
float(NAN) bool(true)
Advertisements