About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Functions - Return Values...

   Browse by title articles:
   What is hot:

Character Classes

Matching/Replacing

Functions - Intro

Functions - Arguments

Functions - Return Values

Include

Running a Program on a Remote Server Using SSH
Be the Master of Your Printer
Newsgroup Security Tips
HTACCESS Wrappers with PHP
Prev articles123456789 10 1112Next articles



Functions - Return Values


Computer & I'net articlesFunctions - Return Values

by David Stanley    



Sometimes you may want to call a function and have a value returned back to the main coding area. This is done using the return command.

Example :

<?php
function addit($first_number,$second_number){
    $total_sum = $first_number + $second_number;
    return $total_sum;
}

$first_number = "1";
$second_number ="2";
$total = addit($first_number,$second_number);
echo "$total";
?>


Result :
3

Leaving the return command out, the result would be blank.
In the above example, the variable $total calls the function entering two arguments. The function takes the numbers and finds the sum. The sum value is "returned" back to the calling variable $total.




-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.





Capital gain




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com