Re: Scope: global $GLOBALS[]

From: Date: Mon, 16 Feb 2004 20:09:35 +0000
Subject: Re: Scope: global $GLOBALS[]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177854@lists.php.net to get a copy of this message
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>


« previous php.general (#177854) next »