Code: Select all
<?php
function numbers()
{
$a = 1;
$b = 1;
$c = 1;
$d = 1;
$e = 1;
$f = 1;
$sum = 0;
add();
echo $sum;
}
function add()
{
global $a, $b, $c, $d, $e, $f, $sum;
$sum = $a + $b + $c + $d + $e + $f;
}
numbers();
?>EDIT: or alternativly, is there a way to pass them all in a single array without having to type them all out? What I don't want to have to do is this:
Code: Select all
<?php
function numbers()
{
$a = 1;
$b = 1;
$c = 1;
$d = 1;
$e = 1;
$f = 1;
$sum = 0;
add(array('a' => &$a, 'b' => &$b, 'c' => &$c, 'd' => &$d, 'e' => &$e, 'f' => &$f, 'sum' => &$sum));
echo $sum;
}
function add($locals)
{
$locals['sum'] = $locals['a'] + $locals['b'] + $locals['c'] + $locals['d'] + $locals['e'] + $locals['f'];
}
numbers();
?>