Professional Web Applications Themes

PHP5 and Global Array ($_GET) - PHP Development

I had a client recently contact me with a script that wasn't working. I quickly isolated the problem as to the fact that the $_GET array was not being made available to all scripts, even though register_globals was set to ON. The client then notified his host who seemed to know exactly the issue and we added these lines to the top of the script (this script is included in all other scripts) and it solved the problems: /* mp.net patch */ foreach($_GET as $var => $value) $$var = $value; foreach($_POST as $var => $value) $$var = $value; foreach($_COOKIE as ...

  1. #1

    Default PHP5 and Global Array ($_GET)

    I had a client recently contact me with a script that wasn't working. I
    quickly isolated the problem as to the fact that the $_GET array was not
    being made available to all scripts, even though register_globals was set to
    ON. The client then notified his host who seemed to know exactly the issue
    and we added these lines to the top of the script (this script is included
    in all other scripts) and it solved the problems:

    /* mp.net patch */
    foreach($_GET as $var => $value) $$var = $value;
    foreach($_POST as $var => $value) $$var = $value;
    foreach($_COOKIE as $var => $value) $$var = $value;
    foreach($_SERVER as $var => $value) $$var = $value;
    ob_start();
    /* end of patch */

    The host added these comments to my client:
    "I can fix that for you, but in a couple of months, PHP5 will be out for
    real, so you might as well want to fix it in your code."

    Is this a work-around for right now or is there some kind of rework that all
    scripts will have to be modified for version 5?

    --
    len
    Raven Web Hosting [url]http://ravenwebhosting.com[/url]
    PHP KISGB PHP Guest Book for Standard and phpNuke sites
    [url]http://www.ravenphpscripts.com[/url]
    PHP KISSQ PHP Stock Quote for Standard and phpNuke sites
    [url]http://www.ravenphpscripts.com[/url]


    gf Guest

  2. #2

    Default Re: PHP5 and Global Array ($_GET)

    "André Nęss" <andrena.spamreallysifi.uio.no> wrote in message
    news:bnf89a$48b$1maud.ifi.uio.no...
    > gf:
    >
    > > I had a client recently contact me with a script that wasn't working. I
    > > quickly isolated the problem as to the fact that the $_GET array was not
    > > being made available to all scripts, even though register_globals was
    set
    > > to
    > > ON. The client then notified his host who seemed to know exactly the
    > > issue and we added these lines to the top of the script (this script is
    > > included in all other scripts) and it solved the problems:
    > >
    > > /* mp.net patch */
    > > foreach($_GET as $var => $value) $$var = $value;
    > > foreach($_POST as $var => $value) $$var = $value;
    > > foreach($_COOKIE as $var => $value) $$var = $value;
    > > foreach($_SERVER as $var => $value) $$var = $value;
    > > ob_start();
    > > /* end of patch */
    >
    > // A simpler solution:
    > extract($_REQUEST);
    > extract($_SESSION);
    >
    > > The host added these comments to my client:
    > > "I can fix that for you, but in a couple of months, PHP5 will be out for
    > > real, so you might as well want to fix it in your code."
    > >
    > > Is this a work-around for right now or is there some kind of rework that
    > > all scripts will have to be modified for version 5?
    >
    > register_globals is considered a bad thing, so you should really strive to
    > move away from it.
    >
    > André Nęss

    That's not the point, though, although I understand. This is not my
    application and the application requires it.

    Can anyone address my original question?

    len
    Raven Web Hosting [url]http://ravenwebhosting.com[/url]
    PHP KISGB PHP Guest Book for Standard and phpNuke sites
    [url]http://www.ravenphpscripts.com[/url]
    PHP KISSQ PHP Stock Quote for Standard and phpNuke sites
    [url]http://www.ravenphpscripts.com[/url]


    gf Guest

  3. #3

    Default Re: PHP5 and Global Array ($_GET)

    gf:
    > I had a client recently contact me with a script that wasn't working. I
    > quickly isolated the problem as to the fact that the $_GET array was not
    > being made available to all scripts, even though register_globals was set
    > to
    > ON. The client then notified his host who seemed to know exactly the
    > issue and we added these lines to the top of the script (this script is
    > included in all other scripts) and it solved the problems:
    >
    > /* mp.net patch */
    > foreach($_GET as $var => $value) $$var = $value;
    > foreach($_POST as $var => $value) $$var = $value;
    > foreach($_COOKIE as $var => $value) $$var = $value;
    > foreach($_SERVER as $var => $value) $$var = $value;
    > ob_start();
    > /* end of patch */
    // A simpler solution:
    extract($_REQUEST);
    extract($_SESSION);
    > The host added these comments to my client:
    > "I can fix that for you, but in a couple of months, PHP5 will be out for
    > real, so you might as well want to fix it in your code."
    >
    > Is this a work-around for right now or is there some kind of rework that
    > all scripts will have to be modified for version 5?
    register_globals is considered a bad thing, so you should really strive to
    move away from it.

    André Nęss
    André Nęss Guest

  4. #4

    Default Re: PHP5 and Global Array ($_GET)

    gf wrote:
    >>>I had a client recently contact me with a script that wasn't working. I
    >>>quickly isolated the problem as to the fact that the $_GET array was not
    >>>being made available to all scripts, even though register_globals was
    >
    > set
    >
    >>>to
    >>>ON.
    Though I am not sure about PHP5 it might be different but perhaps if
    there were no query string parameters passed like script.php?foo=bar
    then PHP has no need to create and populate a $_GET array. This might be
    a bug where when you include() other files it doesn't see it as the same
    request and carry over the super globals. I don't know I have yet to sit
    down and hammer out code for PHP5 given its still beta. Also I always
    use isset() on a variable if its supplied in _GET/_POST/_COOKIE to make
    sure that its actually there. And again tell your client to stop
    requiring register_globals or they might find themselves left in the
    dust, PHP is still a young language and continues to evolve.

    --
    John Downey
    [url]http://delusive.dyn.ee[/url]
    [url]http://sage.dev.box.sk[/url]
    [url]http://blacksun.box.sk[/url]

    John Downey Guest

  5. #5

    Default Re: PHP5 and Global Array ($_GET)

    gf:
    >> register_globals is considered a bad thing, so you should really strive
    >> to move away from it.
    > That's not the point, though, although I understand. This is not my
    > application and the application requires it.
    >
    > Can anyone address my original question?
    Ok, I guess what you're wondering is "Will register globals disappear from
    PHP5?". The answer seems to be no, see: [url]http://zend.com/php/ask_experts.php[/url]
    (currently fifth question from top).

    André Nęss
    André Nęss Guest

  6. #6

    Default Re: PHP5 and Global Array ($_GET)

    "John Downey" <blahdoesntexist.com> wrote in message
    news:%tGmb.165213$xx4.29535333twister.neo.rr.com. ..
    > gf wrote:
    > >>>I had a client recently contact me with a script that wasn't working.
    I
    > >>>quickly isolated the problem as to the fact that the $_GET array was
    not
    > >>>being made available to all scripts, even though register_globals was
    > >
    > > set
    > >
    > >>>to
    > >>>ON.
    > Though I am not sure about PHP5 it might be different but perhaps if
    > there were no query string parameters passed like script.php?foo=bar
    > then PHP has no need to create and populate a $_GET array. This might be
    > a bug where when you include() other files it doesn't see it as the same
    > request and carry over the super globals. I don't know I have yet to sit
    > down and hammer out code for PHP5 given its still beta. Also I always
    > use isset() on a variable if its supplied in _GET/_POST/_COOKIE to make
    > sure that its actually there. And again tell your client to stop
    > requiring register_globals or they might find themselves left in the
    > dust, PHP is still a young language and continues to evolve.
    >
    > --
    > John Downey
    > [url]http://delusive.dyn.ee[/url]
    > [url]http://sage.dev.box.sk[/url]
    > [url]http://blacksun.box.sk[/url]
    >
    They are being passed. This works perfectly on v4.x . There are no issues
    with the way the script is apssing anything. it is directly related to
    something in php5.

    --
    len
    Raven Web Hosting [url]http://ravenwebhosting.com[/url]
    PHP KISGB PHP Guest Book for Standard and phpNuke sites
    [url]http://www.ravenphpscripts.com[/url]
    PHP KISSQ PHP Stock Quote for Standard and phpNuke sites
    [url]http://www.ravenphpscripts.com[/url]


    gf Guest

Similar Threads

  1. php global array help
    By blizbiggy in forum PHP Development
    Replies: 1
    Last Post: June 7th, 04:20 PM
  2. #39011 [NEW]: foreach($_GET as $key => &$value) causes later bugs passing $_GET as a paramete
    By php_bug dot email at email dot digiways dot com in forum PHP Bugs
    Replies: 14
    Last Post: October 2nd, 10:32 AM
  3. array inside a $_GET
    By MLC in forum PHP Development
    Replies: 9
    Last Post: December 11th, 08:30 AM
  4. #24619 [Opn->Csd]: PHP5 crashes on global
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: July 12th, 01:56 PM
  5. #24564 [NEW]: The global variables $_GET, $_REQUEST, $_POST have content errors.
    By php-bug at leolabs dot com in forum PHP Development
    Replies: 0
    Last Post: July 9th, 03:14 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139