Re: Scope: global $GLOBALS[]
| From: | Paul Furman | Date: | Mon, 16 Feb 2004 20:31:27 +0000 |
| Subject: | Re: Scope: global $GLOBALS[] | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177858@lists.php.net to get a copy of this message | ||
The template wipes it out on the second round through after changing in settings. Coming into the template the second time it prints out empty. If I don't use global, the template gives an error that the variable doesn't exist.
OK, well what I'm calling the template is really the configuration file which does an include on the template that includes the screens. I set global in all of those.
Paul Furman wrote:
Help. After changing $pics on the setting screen, the picture screen will not recognize the new value. I'm just not clear where I need to set global (where it's being initially set or where it's being picked up later) especially where it bounces back & forth several times. For now I have global $pics everywhere. Is that bad? Paul Furman wrote:template: -------------------- global $pics; if (!isset($pics)){$pics = 8;} picture screen: -------------------- global $pics; # works fine with the setting 8 from the template settings screen: -------------------- global $pics; print $pics; #for debugging, always follows template setting if (!isset($pics)){$pics = 5;} if ($_POST){if (isset ($_POST['thumbs'])){ $pics = $_POST['thumbs']; print "settings have been changed"; }} ?> <form name="mail" action="<?php SCREEN_DIR . "/settings.php" ?>" method="post"><label for="thumbs">number of thumbnails per page: </label> <input type="text" name="thumbs" id="thumbs" size="2" value="<?php print $pics ?>"> <button type="submit">OK</button></form>