Home Tutorial Php Phpbasics Tutorial PHP Return Statements


PHP Return Statements
Posted on: March 2, 2010 at 12:00 AM
In this php tutorial we will study about the return statement, how to return values, array, objects from a function, examples will help you to understand these concepts precisely.

PHP Returning Statement Values:

PHP Return statement is used to return a value or control to the calling portion of the program. It is an optional statement. In PHP we can return values, arrays, or object.

If the function is called from within the function then execution will immediately stops, return is also used to stop the eval() statement or script file.

PHP Return Statement Example:


function square($var){

return $var*$var;


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



Square of 2 is: 4



function fun(){

return array(0,1,2);



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

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

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



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



Related Tags for PHP Return Statements:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 2, 2010

Recommend the tutorial

Advertisements Advertisements