Firstly, for the record I strongly recommend avoiding both {php}
blocks in Smarty, and global variables. Try to find some other solution to the underlying problem.
That out of the way, you quote this line from the manual, but you haven't followed its advice:
To access PHP variables in {php} blocks you will need to use the PHP global keyword.
What it means is this:
{php}
global $a;
$a = "should be global";
{/php}
Without that, the variable $a
is scoped to whatever function context the generated code is run in. There is no special consideration for "nested" functions or scopes in PHP, so a variable is either global, or visible only inside that one function.