Global variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles O'Flynn

    Global variables

    As a complete newcomer (2-3 days) to PHP, although not to programming in
    general, I have 'dived in' to start a small project to read and parse an XML
    data stream. I have already worked out most of the more specialist aspects
    of the job but am now completely stuck on something I would have thought
    were simplicity itself...
    I need to have a large number of global variables visible inside functions -
    it's not possible to pass them into the functions themselves, since although
    they are user functions, the parameter type/count is fixed. Reading what
    information I can find, I was under the impression that variables declared
    at the head of the PHP block as 'global' would be visible inside all
    functions. My problem is this: yes, it appears I can assign values to
    these global variables inside a function, (I think), but immediately I exit
    the function, the data is lost. At first sight, I could be assigning values
    to variables with identical names but local scope within the functions, but
    when I performed an 'explode()' inside a function, assigning the result to
    one of my 'global' variables and then, on exiting the function, tried to
    'echo' the result, the result was 'ARRAY' - the original global variable had
    presumably been converted, since it started life as a scalar.
    I don't really want to go to superglobals unless I have to - can anybody
    please tell me where I'm going so obviously wrong and how I can correct it?
    This is such a basic problem, I can't help thinking everybody must know the
    answer...
    Thanks for any help/advice offered.


  • Johnny

    #2
    Re: Global variables


    "Charles O'Flynn" <charles@matchw alk.comwrote in message
    news:12hivk1109 pj1e0@corp.supe rnews.com...
    As a complete newcomer (2-3 days) to PHP, although not to programming in
    general, I have 'dived in' to start a small project to read and parse an
    XML
    data stream. I have already worked out most of the more specialist
    aspects
    of the job but am now completely stuck on something I would have thought
    were simplicity itself...
    I need to have a large number of global variables visible inside
    functions -
    it's not possible to pass them into the functions themselves, since
    although
    they are user functions, the parameter type/count is fixed. Reading what
    information I can find, I was under the impression that variables declared
    at the head of the PHP block as 'global' would be visible inside all
    functions. My problem is this: yes, it appears I can assign values to
    these global variables inside a function, (I think), but immediately I
    exit
    the function, the data is lost. At first sight, I could be assigning
    values
    to variables with identical names but local scope within the functions,
    but
    when I performed an 'explode()' inside a function, assigning the result to
    one of my 'global' variables and then, on exiting the function, tried to
    'echo' the result, the result was 'ARRAY' - the original global variable
    had
    presumably been converted, since it started life as a scalar.
    I don't really want to go to superglobals unless I have to - can anybody
    please tell me where I'm going so obviously wrong and how I can correct
    it?
    This is such a basic problem, I can't help thinking everybody must know
    the
    answer...
    Thanks for any help/advice offered.
    >
    >
    just need to use the global keyword when inside the function, it's explained
    here:



    Comment

    • Charles O'Flynn

      #3
      Re: Global variables

      "Johnny" <removethis.huu anito@hotmail.c omwrote in message
      news:lsfSg.375$ UJ2.143@fed1rea d07...
      |
      | "Charles O'Flynn" <charles@matchw alk.comwrote in message
      | news:12hivk1109 pj1e0@corp.supe rnews.com...
      | As a complete newcomer (2-3 days) to PHP, although not to programming in
      | general, I have 'dived in' to start a small project to read and parse an
      | XML
      | data stream. I have already worked out most of the more specialist
      | aspects
      | of the job but am now completely stuck on something I would have thought
      | were simplicity itself...
      | I need to have a large number of global variables visible inside
      | functions -
      | it's not possible to pass them into the functions themselves, since
      | although
      | they are user functions, the parameter type/count is fixed. Reading
      what
      | information I can find, I was under the impression that variables
      declared
      | at the head of the PHP block as 'global' would be visible inside all
      | functions. My problem is this: yes, it appears I can assign values to
      | these global variables inside a function, (I think), but immediately I
      | exit
      | the function, the data is lost. At first sight, I could be assigning
      | values
      | to variables with identical names but local scope within the functions,
      | but
      | when I performed an 'explode()' inside a function, assigning the result
      to
      | one of my 'global' variables and then, on exiting the function, tried to
      | 'echo' the result, the result was 'ARRAY' - the original global variable
      | had
      | presumably been converted, since it started life as a scalar.
      | I don't really want to go to superglobals unless I have to - can anybody
      | please tell me where I'm going so obviously wrong and how I can correct
      | it?
      | This is such a basic problem, I can't help thinking everybody must know
      | the
      | answer...
      | Thanks for any help/advice offered.
      | >
      | >
      |
      | just need to use the global keyword when inside the function, it's
      explained
      | here:
      | http://us3.php.net/global
      |
      Thanks for the quick reply, Johnny, but I've been looking at the page you
      refer to all afternoon and it doesn't seem to work for me. For instance,
      (and I'm only illustrating the specific problem I seem to have hereunder)...
      ------------------------------------
      $variable;

      function printsomething( )
      {
      global $variable;

      $variable = 'Test'.<b />;
      echo $variable;
      }

      printsomething( );
      echo $variable;
      ------------------------------------

      ....only prints one line of 'Test' - I'd have thought it should print out two
      copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
      change/upgrade!)
      Thanks and regards,
      Charles


      Comment

      • Charles O'Flynn

        #4
        Re: Global variables


        "Charles O'Flynn" <charles@matchw alk.comwrote in message
        news:12hj3sqtit kuid7@corp.supe rnews.com...
        | "Johnny" <removethis.huu anito@hotmail.c omwrote in message
        | news:lsfSg.375$ UJ2.143@fed1rea d07...
        ||
        || "Charles O'Flynn" <charles@matchw alk.comwrote in message
        || news:12hivk1109 pj1e0@corp.supe rnews.com...
        || As a complete newcomer (2-3 days) to PHP, although not to programming
        in
        || general, I have 'dived in' to start a small project to read and parse
        an
        || XML
        || data stream. I have already worked out most of the more specialist
        || aspects
        || of the job but am now completely stuck on something I would have
        thought
        || were simplicity itself...
        || I need to have a large number of global variables visible inside
        || functions -
        || it's not possible to pass them into the functions themselves, since
        || although
        || they are user functions, the parameter type/count is fixed. Reading
        | what
        || information I can find, I was under the impression that variables
        | declared
        || at the head of the PHP block as 'global' would be visible inside all
        || functions. My problem is this: yes, it appears I can assign values to
        || these global variables inside a function, (I think), but immediately I
        || exit
        || the function, the data is lost. At first sight, I could be assigning
        || values
        || to variables with identical names but local scope within the functions,
        || but
        || when I performed an 'explode()' inside a function, assigning the result
        | to
        || one of my 'global' variables and then, on exiting the function, tried
        to
        || 'echo' the result, the result was 'ARRAY' - the original global
        variable
        || had
        || presumably been converted, since it started life as a scalar.
        || I don't really want to go to superglobals unless I have to - can
        anybody
        || please tell me where I'm going so obviously wrong and how I can correct
        || it?
        || This is such a basic problem, I can't help thinking everybody must know
        || the
        || answer...
        || Thanks for any help/advice offered.
        || >
        || >
        ||
        || just need to use the global keyword when inside the function, it's
        | explained
        || here:
        || http://us3.php.net/global
        ||
        | Thanks for the quick reply, Johnny, but I've been looking at the page you
        | refer to all afternoon and it doesn't seem to work for me. For instance,
        | (and I'm only illustrating the specific problem I seem to have
        hereunder)...
        | ------------------------------------
        | $variable;
        |
        | function printsomething( )
        | {
        | global $variable;
        |
        | $variable = 'Test'.<b />;
        | echo $variable;
        | }
        |
        | printsomething( );
        | echo $variable;
        | ------------------------------------
        |
        | ...only prints one line of 'Test' - I'd have thought it should print out
        two
        | copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
        | change/upgrade!)
        | Thanks and regards,
        | Charles
        |
        *************** *************** *************** ***********
        I thought I'd just try out what I wrote above and loaded this up...

        <?php
        $loc_place;

        function writesomething( )
        {
        global $loc_place;

        $loc_place = 'This is a test';
        echo $loc_place.'<br />';
        }

        echo $loc_place.' again<br />';
        writesomething( );
        ?>

        As I wrote earlier, I get no sign of any output from outside the function,
        only inside...

        This is a test

        Surely this cannot be right?


        Comment

        • Jerry Stuckle

          #5
          Re: Global variables

          Charles O'Flynn wrote:
          "Johnny" <removethis.huu anito@hotmail.c omwrote in message
          news:lsfSg.375$ UJ2.143@fed1rea d07...
          |
          | "Charles O'Flynn" <charles@matchw alk.comwrote in message
          | news:12hivk1109 pj1e0@corp.supe rnews.com...
          | As a complete newcomer (2-3 days) to PHP, although not to programming in
          | general, I have 'dived in' to start a small project to read and parse an
          | XML
          | data stream. I have already worked out most of the more specialist
          | aspects
          | of the job but am now completely stuck on something I would have thought
          | were simplicity itself...
          | I need to have a large number of global variables visible inside
          | functions -
          | it's not possible to pass them into the functions themselves, since
          | although
          | they are user functions, the parameter type/count is fixed. Reading
          what
          | information I can find, I was under the impression that variables
          declared
          | at the head of the PHP block as 'global' would be visible inside all
          | functions. My problem is this: yes, it appears I can assign values to
          | these global variables inside a function, (I think), but immediately I
          | exit
          | the function, the data is lost. At first sight, I could be assigning
          | values
          | to variables with identical names but local scope within the functions,
          | but
          | when I performed an 'explode()' inside a function, assigning the result
          to
          | one of my 'global' variables and then, on exiting the function, tried to
          | 'echo' the result, the result was 'ARRAY' - the original global variable
          | had
          | presumably been converted, since it started life as a scalar.
          | I don't really want to go to superglobals unless I have to - can anybody
          | please tell me where I'm going so obviously wrong and how I can correct
          | it?
          | This is such a basic problem, I can't help thinking everybody must know
          | the
          | answer...
          | Thanks for any help/advice offered.
          | >
          | >
          |
          | just need to use the global keyword when inside the function, it's
          explained
          | here:
          | http://us3.php.net/global
          |
          Thanks for the quick reply, Johnny, but I've been looking at the page you
          refer to all afternoon and it doesn't seem to work for me. For instance,
          (and I'm only illustrating the specific problem I seem to have hereunder)...
          ------------------------------------
          $variable;
          >
          function printsomething( )
          {
          global $variable;
          >
          $variable = 'Test'.<b />;
          echo $variable;
          }
          >
          printsomething( );
          echo $variable;
          ------------------------------------
          >
          ...only prints one line of 'Test' - I'd have thought it should print out two
          copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
          change/upgrade!)
          Thanks and regards,
          Charles
          >
          >
          You're close. But you have to use the global keyword in the global
          context, also. Not just in the function.

          global $variable;

          function printsomething( )
          {
          global $variable;

          $variable = 'Test'.<b />;
          echo $variable;
          }

          printsomething( );
          echo $variable;

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Charles O'Flynn

            #6
            Re: Global variables

            "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
            news:ytCdnSaj__ sJC4TYnZ2dnUVZ_ tidnZ2d@comcast .com...
            | Charles O'Flynn wrote:
            | "Johnny" <removethis.huu anito@hotmail.c omwrote in message
            | news:lsfSg.375$ UJ2.143@fed1rea d07...
            | |
            | | "Charles O'Flynn" <charles@matchw alk.comwrote in message
            | | news:12hivk1109 pj1e0@corp.supe rnews.com...
            | | As a complete newcomer (2-3 days) to PHP, although not to
            programming in
            | | general, I have 'dived in' to start a small project to read and
            parse an
            | | XML
            | | data stream. I have already worked out most of the more specialist
            | | aspects
            | | of the job but am now completely stuck on something I would have
            thought
            | | were simplicity itself...
            | | I need to have a large number of global variables visible inside
            | | functions -
            | | it's not possible to pass them into the functions themselves, since
            | | although
            | | they are user functions, the parameter type/count is fixed. Reading
            | what
            | | information I can find, I was under the impression that variables
            | declared
            | | at the head of the PHP block as 'global' would be visible inside all
            | | functions. My problem is this: yes, it appears I can assign values
            to
            | | these global variables inside a function, (I think), but immediately
            I
            | | exit
            | | the function, the data is lost. At first sight, I could be
            assigning
            | | values
            | | to variables with identical names but local scope within the
            functions,
            | | but
            | | when I performed an 'explode()' inside a function, assigning the
            result
            | to
            | | one of my 'global' variables and then, on exiting the function,
            tried to
            | | 'echo' the result, the result was 'ARRAY' - the original global
            variable
            | | had
            | | presumably been converted, since it started life as a scalar.
            | | I don't really want to go to superglobals unless I have to - can
            anybody
            | | please tell me where I'm going so obviously wrong and how I can
            correct
            | | it?
            | | This is such a basic problem, I can't help thinking everybody must
            know
            | | the
            | | answer...
            | | Thanks for any help/advice offered.
            | | >
            | | >
            | |
            | | just need to use the global keyword when inside the function, it's
            | explained
            | | here:
            | | http://us3.php.net/global
            | |
            | Thanks for the quick reply, Johnny, but I've been looking at the page
            you
            | refer to all afternoon and it doesn't seem to work for me. For
            instance,
            | (and I'm only illustrating the specific problem I seem to have
            hereunder)...
            | ------------------------------------
            | $variable;
            | >
            | function printsomething( )
            | {
            | global $variable;
            | >
            | $variable = 'Test'.<br />;
            | echo $variable;
            | }
            | >
            | printsomething( );
            | echo $variable;
            | ------------------------------------
            | >
            | ...only prints one line of 'Test' - I'd have thought it should print out
            two
            | copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
            | change/upgrade!)
            | Thanks and regards,
            | Charles
            | >
            | >
            |
            | You're close. But you have to use the global keyword in the global
            | context, also. Not just in the function.
            |
            | global $variable;
            |
            | function printsomething( )
            | {
            | global $variable;
            |
            | $variable = 'Test'.<br />;
            | echo $variable;
            | }
            |
            | printsomething( );
            | echo $variable;
            |
            | --
            | =============== ===
            | Remove the "x" from my email address
            | Jerry Stuckle
            | JDS Computer Training Corp.
            | jstucklex@attgl obal.net
            | =============== ===

            Thanks, but I've tried that and it still doesn't work.
            I'm getting the feeling PHP doesn't like me, although I like it well
            enough...


            Comment

            • Oli Filth

              #7
              Re: Global variables

              Jerry Stuckle said the following on 26/09/2006 22:07:
              Charles O'Flynn wrote:
              >Thanks for the quick reply, Johnny, but I've been looking at the page you
              >refer to all afternoon and it doesn't seem to work for me. For instance,
              >(and I'm only illustrating the specific problem I seem to have
              >hereunder).. .
              >------------------------------------
              >$variable;
              >>
              >function printsomething( )
              >{
              > global $variable;
              >>
              > $variable = 'Test'.<b />;
              > echo $variable;
              >}
              >>
              >printsomething ();
              >echo $variable;
              >------------------------------------
              >>
              >...only prints one line of 'Test' - I'd have thought it should print
              >out two
              >copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
              >change/upgrade!)
              >
              You're close. But you have to use the global keyword in the global
              context, also. Not just in the function.
              Umm, no you don't!

              >
              global $variable;
              >
              function printsomething( )
              {
              global $variable;
              >
              $variable = 'Test'.<b />;
              echo $variable;
              }
              >
              printsomething( );
              echo $variable;
              >

              --
              Oli

              Comment

              • Oli Filth

                #8
                Re: Global variables

                Charles O'Flynn said the following on 26/09/2006 22:05:
                I thought I'd just try out what I wrote above and loaded this up...
                >
                <?php
                $loc_place;
                >
                function writesomething( )
                {
                global $loc_place;
                >
                $loc_place = 'This is a test';
                echo $loc_place.'<br />';
                }
                >
                echo $loc_place.' again<br />';
                writesomething( );
                ?>
                >
                As I wrote earlier, I get no sign of any output from outside the function,
                only inside...
                >
                This is a test
                Well, in this code, $loc_place has no value assigned before
                writesomething( ) is called. Depending on your error settings and
                version, I guess the echo $loc_place.' again<br />' line might fail
                silently; although in PHP 5 it just echoes " again<br />". I don't have
                PHP 4 running to test the behaviour.


                --
                Oli

                Comment

                • Charles O'Flynn

                  #9
                  Re: Global variables


                  "Oli Filth" <catch@olifilth .co.ukwrote in message
                  news:fEiSg.3226 4$TF5.8307@news fe1-win.ntli.net...
                  | Jerry Stuckle said the following on 26/09/2006 22:07:
                  | Charles O'Flynn wrote:
                  | >Thanks for the quick reply, Johnny, but I've been looking at the page
                  you
                  | >refer to all afternoon and it doesn't seem to work for me. For
                  instance,
                  | >(and I'm only illustrating the specific problem I seem to have
                  | >hereunder).. .
                  | >------------------------------------
                  | >$variable;
                  | >>
                  | >function printsomething( )
                  | >{
                  | > global $variable;
                  | >>
                  | > $variable = 'Test'.<b />;
                  | > echo $variable;
                  | >}
                  | >>
                  | >printsomething ();
                  | >echo $variable;
                  | >------------------------------------
                  | >>
                  | >...only prints one line of 'Test' - I'd have thought it should print
                  | >out two
                  | >copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
                  | >change/upgrade!)
                  | >
                  | You're close. But you have to use the global keyword in the global
                  | context, also. Not just in the function.
                  |
                  | Umm, no you don't!
                  |

                  |
                  | >
                  | global $variable;
                  | >
                  | function printsomething( )
                  | {
                  | global $variable;
                  | >
                  | $variable = 'Test'.<b />;
                  | echo $variable;
                  | }
                  | >
                  | printsomething( );
                  | echo $variable;
                  | >
                  |
                  |
                  | --
                  | Oli


                  Thanks, Oli
                  I'm getting the feeling, (although noone's spelling it out either here or in
                  any of the myriad books I've looked at for inspiration), that declaring a
                  variable as global inside a function will make it accessible outside the
                  function at the global scope; in other words, what I've done above is
                  declare two independent variables, the one outside the function over-riding
                  the effect of the one inside the function.. OK - I can test this very
                  quickly. But if so, how on earth do I get to access it within another
                  function, or does this automatically make it visible everywhere?
                  Of course, I could store the data within MySQL, thereby making it
                  persistent, but this seems like overkill. How does PHP make variables
                  accessible with 'real' global scope, not just 'global, except inside
                  functions', which for an old 'C' programmer like me, is not global at all?
                  I know, in theory about superglobals but again, this seems like overkill.
                  Or am I being silly?
                  Thanks,
                  Charles


                  Comment

                  • Charles O'Flynn

                    #10
                    Re: Global variables

                    "Charles O'Flynn" <charles@matchw alk.comwrote in message
                    news:12hka05ljf ihp35@corp.supe rnews.com...
                    |
                    | "Oli Filth" <catch@olifilth .co.ukwrote in message
                    | news:fEiSg.3226 4$TF5.8307@news fe1-win.ntli.net...
                    || Jerry Stuckle said the following on 26/09/2006 22:07:
                    || Charles O'Flynn wrote:
                    || >Thanks for the quick reply, Johnny, but I've been looking at the page
                    | you
                    || >refer to all afternoon and it doesn't seem to work for me. For
                    | instance,
                    || >(and I'm only illustrating the specific problem I seem to have
                    || >hereunder).. .
                    || >------------------------------------
                    || >$variable;
                    || >>
                    || >function printsomething( )
                    || >{
                    || > global $variable;
                    || >>
                    || > $variable = 'Test'.<b />;
                    || > echo $variable;
                    || >}
                    || >>
                    || >printsomething ();
                    || >echo $variable;
                    || >------------------------------------
                    || >>
                    || >...only prints one line of 'Test' - I'd have thought it should print
                    || >out two
                    || >copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
                    || >change/upgrade!)
                    || >
                    || You're close. But you have to use the global keyword in the global
                    || context, also. Not just in the function.
                    ||
                    || Umm, no you don't!
                    ||
                    |

                    ||
                    || >
                    || global $variable;
                    || >
                    || function printsomething( )
                    || {
                    || global $variable;
                    || >
                    || $variable = 'Test'.<b />;
                    || echo $variable;
                    || }
                    || >
                    || printsomething( );
                    || echo $variable;
                    || >
                    ||
                    ||
                    || --
                    || Oli
                    |
                    |
                    | Thanks, Oli
                    | I'm getting the feeling, (although noone's spelling it out either here or
                    in
                    | any of the myriad books I've looked at for inspiration), that declaring a
                    | variable as global inside a function will make it accessible outside the
                    | function at the global scope; in other words, what I've done above is
                    | declare two independent variables, the one outside the function
                    over-riding
                    | the effect of the one inside the function.. OK - I can test this very
                    | quickly. But if so, how on earth do I get to access it within another
                    | function, or does this automatically make it visible everywhere?
                    | Of course, I could store the data within MySQL, thereby making it
                    | persistent, but this seems like overkill. How does PHP make variables
                    | accessible with 'real' global scope, not just 'global, except inside
                    | functions', which for an old 'C' programmer like me, is not global at all?
                    | I know, in theory about superglobals but again, this seems like overkill.
                    | Or am I being silly?
                    | Thanks,
                    | Charles
                    |


                    Problem now solved (from the point of view of this specific query). Thanks
                    to Oli, Norm and Johnny for taking the trouble to reply.
                    Regards,
                    Charles


                    Comment

                    • Norman Peelman

                      #11
                      Re: Global variables

                      "Charles O'Flynn" <charles@matchw alk.comwrote in message
                      news:12hkbhi2nn hpo27@corp.supe rnews.com...
                      "Charles O'Flynn" <charles@matchw alk.comwrote in message
                      news:12hka05ljf ihp35@corp.supe rnews.com...
                      |
                      | "Oli Filth" <catch@olifilth .co.ukwrote in message
                      | news:fEiSg.3226 4$TF5.8307@news fe1-win.ntli.net...
                      || Jerry Stuckle said the following on 26/09/2006 22:07:
                      || Charles O'Flynn wrote:
                      || >Thanks for the quick reply, Johnny, but I've been looking at the
                      page
                      | you
                      || >refer to all afternoon and it doesn't seem to work for me. For
                      | instance,
                      || >(and I'm only illustrating the specific problem I seem to have
                      || >hereunder).. .
                      || >------------------------------------
                      || >$variable;
                      || >>
                      || >function printsomething( )
                      || >{
                      || > global $variable;
                      || >>
                      || > $variable = 'Test'.<b />;
                      || > echo $variable;
                      || >}
                      || >>
                      || >printsomething ();
                      || >echo $variable;
                      || >------------------------------------
                      || >>
                      || >...only prints one line of 'Test' - I'd have thought it should print
                      || >out two
                      || >copies. BTW, I'm running under PHP 4.1.2 (and it's not mine to
                      || >change/upgrade!)
                      || >
                      || You're close. But you have to use the global keyword in the global
                      || context, also. Not just in the function.
                      ||
                      || Umm, no you don't!
                      ||
                      |
                      >
                      http://uk.php.net/manual/en/language...s.scope.global
                      ||
                      || >
                      || global $variable;
                      || >
                      || function printsomething( )
                      || {
                      || global $variable;
                      || >
                      || $variable = 'Test'.<b />;
                      || echo $variable;
                      || }
                      || >
                      || printsomething( );
                      || echo $variable;
                      || >
                      ||
                      ||
                      || --
                      || Oli
                      |
                      |
                      | Thanks, Oli
                      | I'm getting the feeling, (although noone's spelling it out either here
                      or
                      in
                      | any of the myriad books I've looked at for inspiration), that declaring
                      a
                      | variable as global inside a function will make it accessible outside the
                      | function at the global scope; in other words, what I've done above is
                      | declare two independent variables, the one outside the function
                      over-riding
                      | the effect of the one inside the function.. OK - I can test this very
                      | quickly. But if so, how on earth do I get to access it within another
                      | function, or does this automatically make it visible everywhere?
                      | Of course, I could store the data within MySQL, thereby making it
                      | persistent, but this seems like overkill. How does PHP make variables
                      | accessible with 'real' global scope, not just 'global, except inside
                      | functions', which for an old 'C' programmer like me, is not global at
                      all?
                      | I know, in theory about superglobals but again, this seems like
                      overkill.
                      | Or am I being silly?
                      | Thanks,
                      | Charles
                      |
                      >
                      >
                      Problem now solved (from the point of view of this specific query).
                      Thanks
                      to Oli, Norm and Johnny for taking the trouble to reply.
                      Regards,
                      Charles
                      >
                      Of course, there's always the $_GLOBALS array...

                      Norm


                      Comment

                      Working...