I have a function that uses lots of global vars and arrays - e.g.
$a=1;
$b[0]=\'a\';
$b[1]=\'b\';
$c=\'Hello\';
function foo() {
echo \"$a
$b[0]
You can access global vars with global
keyword:
global $a=1;
global $b[0]='a';
global $b[1]='b';
global $c='Hello';
function foo() {
global $a, $b, $c;
echo "$a
$b[0]
$b[1]
$c";
}
Otherwise you can use predefined $GLOBALS
array:
function foo() {
echo "$GLOBALS['a']
$GLOBALS['b'][0]
$GLOBALS['b'][1]
$GLOBALS[c]";
}
Here you have more info:
http://php.net/manual/en/language.variables.scope.php