PHP Return
Posted on: March 29, 2010 at 12:00 AM
In this tutorial we will study about bitwise operator, bitwise operator works on bit or binary number of an integer value. Examples in this tutorial will make it more clear.

Return Statement:

Return statement is used within a function to return a value (or multiple values using array in PHP) or the control to the calling line from the function. After getting a return statement the PHP parser ignores the rest of the coding.

Return or return() is a language construct, it is not always necessary to put parenthesis after return statement. If no value is returned from the return statement then it is mandatory to remove the parenthesis from return statement otherwise a parse error.  

Example:

<?php

function square($var){

return $var*$var;

}

echo "Square of 2 is: ".square(2);

?>

Output:

Square of 2 is: 4

Example:

<?php

function fun(){

return array(0,1,2);

}

list($var1,$var2,$var3)=fun();

echo "Value of \$var1= ".$var1."<br/>";

echo "Value of \$var2= ".$var2."<br/>";

echo "Value of \$var3= ".$var3."<br/>";

?>

Output:

Value of $var1= 0
Value of $var2= 1
Value of $var3= 2

 

Related Tags for PHP Return :


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.