Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

functions.returning values function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php functions.returning values () function

Write your php code

 
<?php ?>

Php Result


Your code below



Returning values

Values are returned by using the optional return statement. Any type may be returned, including lists and objects. This causes the function to end its execution immediately and pass control back to the line from which it was called. See return() for more information.

Example 17-11. Use of return()

<?php
function square($num)
{
    return
$num * $num;
}
echo
square(4);   // outputs '16'.
?>

You can't return multiple values from a function, but similar results can be obtained by returning a list.

Example 17-12. Returning an array to get multiple values

<?php
function small_numbers()
{
    return array (
0, 1, 2);
}
list (
$zero, $one, $two) = small_numbers();
?>

To return a reference from a function, you have to use the reference operator & in both the function declaration and when assigning the returned value to a variable:

Example 17-13. Returning a reference from a function

<?php
function &returns_reference()
{
    return
$someref;
}

$newref =& returns_reference();
?>

For more information on references, please check out References Explained.

Php functions.returning values Function syntax tag

functions.returning values php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php functions.returning values syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online