note 114069 added to function.return
| From: | david1989mail at yahoo dot com | Date: | Wed, 08 Jan 2014 16:26:57 +0000 |
| Subject: | note 114069 added to function.return | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198158@lists.php.net to get a copy of this message | ||
You could use this in Functions:
<?php
function function_name($number){
$result = $number*2;
return $result;
}
//Direct:
echo function_name(3);
//Or with a variable:
$var = function_name(4);
echo $var;
?>
This will return and show on the screen number 6 and 8.
Using return is much better, because you get the function as a variable, and you can easily use
string functions.
The way without return:
<?php
function function_name($number){
$result = $number*2;
echo $result;
}
function_name(3);
?>
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/function.return.php
Edit -- https://master.php.net/note/edit/114069
Del: integrated -- https://master.php.net/note/delete/114069/integrated
Del: useless -- https://master.php.net/note/delete/114069/useless
Del: bad code -- https://master.php.net/note/delete/114069/bad+code
Del: spam -- https://master.php.net/note/delete/114069/spam
Del: non-english -- https://master.php.net/note/delete/114069/non-english
Del: in docs -- https://master.php.net/note/delete/114069/in+docs
Del: other reasons-- https://master.php.net/note/delete/114069
Reject -- https://master.php.net/note/reject/114069
Search -- https://master.php.net/manage/user-notes.php