Return is a language construct, it is not a function, hence parentheses are not required to surround the arguments. If no arguments are provided NULL is returned. |
<?php $num = 22; function evenOddTest($no){ if($no%2 ==0) { return "$no is even"; } else { return "$no is odd"; } } echo evenOddTest($num); ?>
Example 2:Output
22 is even
<?php function nothingToDo(){ echo "This function returns noting, hence var_dump returns : "; } //var_dump() returns NULL if function has no return! echo var_dump(nothingToDo()); ?>
Output
This function returns noting, hence var_dump returns : NULL