+

# PHP Is_finite (), is_infinite (), is_nan () functions

So this is a safe way to check if a given input is finite or not. is_finite() Syntax:
`bool is_finite (\$value)`
Parameters : the function takes one parameter, which is floating point to be checked.Return type : This function returns TRUE if the given value is finite, FALSE otherwise.Examples:
`Input: \$value = M_PI_4; Output: TRUE Input: \$value = log (0); Output: FALSE`
is_infinite() Syntax:
`bool is_infinite (\$value)`
Parameters : the function takes one parameter, which is a floating point that must be checked.Return type : This function returns TRUE if the given value is infinite, FALSE otherwise.Examples:
`Input: \$value = M_PI_4; Output: FALSE Input: \$value = log (0); Output: TRUE`
is_nan() function Syntax:
`bool is_nan (\$value)`
Parameters : the function takes one parameter, which is a floating point that must be checked. Return type : This function returns TRUE if the given value is not a number, FALSE otherwise.Examples:
`Input: \$value = M_PI_4; Output: FALSE Input: \$value = acos (1.1); // cos function can not be greater than 1 Output: TRUE`
The program below illustrates the operation of the is_finite(), is_infinite(), is_nan() functions in PHP: ```   // PHP -code to illustrate the work // Functions is_finite(), is_infinte() and is_nan()  // Final value: PI \$val1 = M_PI; // Embedded INFINITY value \$val2 = INF; // Creates NaN because the COS value can be found // from -1 up to +1 both inclusive \$val3 = acos (- 1.01); echo var_dump ( is_finite ( \$val1 ), is_finite ( \$val2 ), is_finite ( \$val3 )). " " ; echo var_dump ( is_infinite ( \$val1 ), is_infinite ( \$val2 ), is_infinite ( \$val3 )). "" ; echo var_dump ( is_nan ( \$val1 ), is_nan ( \$val2 ), is_nan ( \$val3 )). "" ;   ?> Output:bool (true ) bool (false) bool (false) bool (false) bool (true) bool (false) bool (false) bool (false) bool (true) to watch out for : This function can also check if an expression produces an end result, but in the case of expressions that result in NaN, PHP itself shows an error and returns FALSE by default , for example, when checking the Divided by Zero expression. The is_finite() function is used in many projects to make it safer and more efficient. These methods give very accurate results, but not very time efficient. ```
``` ```
``` ```
``` ```
``` Get Solution for free from DataCamp guru © 2021 Python.Engineering Best Python tutorials books for beginners and professionals Python.Engineering is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com Computations Development Cryptography For dummies Machine Learning Big Data Loops Counters NumPy NLP PHP Regular Expressions File Handling Arrays String Variables Knowledge Database X Submit new EBook \$(document).ready(function () { \$(".modal_galery").owlCarousel({ items: 1, itemsCustom: false, itemsDesktop: [1300, 1], itemsDesktopSmall: [960, 1], itemsTablet: [768, 1], itemsTabletSmall: false, itemsMobile: [479, 1], singleItem: false, itemsScaleUp: false, pagination: false, navigation: true, rewindNav: true, autoPlay: true, stopOnHover: true, navigationText: [ "<img class='img_no_nav_mob' src='/wp-content/themes/nimani/image/prevCopy.png'>", "<img class='img_no_nav_mob' src='/wp-content/themes/nimani/image/nextCopy.png'>" ], }); \$(".tel_mask").mask("+9(999) 999-99-99"); }) ```