global vars in templates

From: Date: Sun, 14 Apr 2002 22:07:58 +0000
Subject: global vars in templates
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3714@lists.php.net to get a copy of this message
Hi - I am having a problem making global vars in templates work. Here's the sitation: 1. The template includes test.php {php} include("c:\apache\htdocs\test.php") {/php} 2. test.php is simply: <?php $a = 123; test_a(); function test_a() { global $a; if ($a == 123) { echo "yeah it works!"; } else { echo "no luck-- bummer dude"; } } ?> The variable $a is not carried down into the function test_a, even though I use the 'global' command. (It works fine, of course, if I just include the file in PHP file for the page, instead of trying to have the template do the include.) Why does this happen? Does it have something to do with variable scoping around classes? Is there a way to work around this? thank you very much, Eric http://ericmueller.org

« previous php.smarty.general (#3714) next »