| Posted by Jim Carlock on 02/01/06 02:27 
"Al" <alexrussell101@gmail.com> wrote:> Just use global $counter_file; in your function.
 > See http://uk2.php.net/global#language.variables.scope.global for
 > usage.
 >
 > The global keyword will basically open up the variable for use
 > by your function. An alternative:
 >
 >   $counter_file = $GLOBALS["counter_file"];
 >
 > but that creates a local copy. However,
 >
 >   $counter_file = &$GLOBALS["counter_file"];
 >
 > creates a read/writable reference like the global keyword.
 > That way you can call it whatever you like.
 
 Thanks Alex (or Al).
 
 Breaking out of old global variable ways is going to be interesting.
 What an interesting way to handle global variables.
 
 Is there a way to require variable pre-declarations? Where the
 parsing unit throws up an error if a variable is not predeclared?
 
 For instance, the .asp ways and means...
 
 Option Explicit
 Dim sCounterFile
 sCounterFile = "counter.txt"
 
 Thanks for explaining "global" and "GLOBALS[]".
 
 Jim Carlock
 Post replies to the newsgroup.
 [Back to original message] |