LB1234
asked on
Why doesn't this code work?
Don't understand why this isn't working. When run, I get nothing in the browser.
<?php
function add ($x, $y) {
$num = $x + $y;
return $num;
}
add(3,4);
echo $num;
?>
If you don't need to assign it, then:
echo add(3,4);
ASKER
I thought the whole point of "return" was to make sure something could be used OUTSIDE the function?
ASKER
If I return "$num" shouldn't $num be available outside the variable?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window