My PHP functions cannot reference global PHP variables
PHP used within a template is processed by the PHP function eval(). Because of this, variables in your PHP code are all considered to be of local scope, and your functions will not be able to reference them unless they are explicitly declared as globals.
Incorrect implementation:
<?php
$foo = 'Hello World!';
bar();
function bar() {
global $foo;
echo $foo;
}
?>
Correct implementation:
<?php
global $foo;
$foo = 'Hello World!';
bar();
function bar() {
global $foo;
echo $foo;
}
?>
