Question 2:
$somevar=1;
function somefunc()
{ global $somevar;
$somevar=2;
}
Question 1:
Any variables defined with global scope are accessible as elements of the $GLOBALS array:
$somevar=1;
function somefunc()
{ $GLOBALS['somevar']=2;
}
Of couse, for convenience you might want to create a reference to the $GLOBALS element
$somevar=1;
function somefunc()
{ $somevar=&$GLOBALS['somevar'];
$somevar=2;
}
(A reference so that the global $somevar gets updated.)
But then the first line of that function could be achieved by
$somevar=1;
function somefunc()
{ global $somevar;
$somevar=2;
}
And you're back to Question 2.