Posted by windandwaves on 10/12/06 03:54
Hi Folk
Consider the two code options below. I want to know if it makes more
sense, in theory, to pass a variable or to make it global
FIRST OPTION --
....
$data = 5;
$data = dosomething($data)
....
echo $data;
exit();
function dosomething($data) {
$myval = 3;
$data = $data + $myval;
return $data;
}
SECOND OPTION --
....
$data = 5;
dosomething()
....
echo $data;
exit();
function dosomething() {
global $data;
$myval = 3;
$data = $data + $myval;
}
[Back to original message]
|