I am writing a function, with the name max_number, which returns the maximum of a number numbers variable. If one of the arguments is not a number, then it returns false. Using the is_numeric () function. But the function always returns false. Will I do something wrong?
The code and this:
<?php function max_number() { $args = func_get_args(); if( $args !== null && !is_numeric($args)){ echo "false"; } else{ echo "Maximo number is: " . max($args); } } max_number(1,2,3,4,5); ?>
Advertisement
Answer
<?php function max_number() { $args = func_get_args(); if( $args == null && !is_numeric($args)){ echo "false"; } else{ echo "Maximo number is: " . max($args); } } max_number(1,2,3,4,5); ?>