PHP Function Return

Description

Function can return one value back from functions by using the return statement.

Note

If you try to assign to a variable the return value of a function that has no return value, your variable will be set to NULL.

Example

Return value from a function


<?PHP/*from w  w w.  ja  va2  s .c  o  m*/
function foo() { 
       print "In function"; 
       return 1; 
       print "Leaving function..."; 
} 
print foo(); 
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition