Return in a function - PHP -
even if understand doing,i can't seem find logic in return $totaal
does. below working code:
<?php function adding ($getal1, $getal2){ $totaal = $getal1 + $getal2; homecoming $totaal; } function substract ($getal1, $getal2){ $totaal = $getal1 - $getal2; homecoming $totaal; } $getal1=10; $getal2=2; echo adding ($getal1, $getal2) . "<br>"; echo substract ($getal1, $getal2); ?>
i create function , phone call later echo'ing return $totaal
in function. never phone call it, without homecoming blanks.
i must missing kind of logic in brains....
return
word says returns (gives back) something. in case either $var1 + $var2
or $var1 - $var2
.
variables within of function can't accessed outside of it. return
can within function utilize oustide of it.
keep in mind, return
end execution of function.
php
No comments:
Post a Comment