Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2006

    Thumbs up Unanswered: PHP: How do I deal with GLOBALS?

    Hi all,

    I read in php manual:

    Global variables: $GLOBALS
    Note: $GLOBALS has been available since PHP 3.0.0.

    An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.

    This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $GLOBALS; to access it within functions or methods.
    So If You don't need to do a global $GLOBALS, how to deal with this $GLOBALS so that the variable exist in function.

    I made example below:


    $basic_url = '';

    $myvar = GLOBALS ..........;

    function whatever() {

    echo $myvar;


    whatever(); // would print ''


    How to deal with the $GLOBALS so the above script will produce '' without making a global $GLOBALS.

    Please advise..
    Monty Auto
    One of The Fastest Growing Online Business Available Today.

  2. #2
    Join Date
    Apr 2006
    Denver, Co. USA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts