473,388 Members | 897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 */

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?

--
Gaylen
Raven Web Hosting http://ravenwebhosting.com
PHP KISGB PHP Guest Book for Standard and phpNuke sites
http://www.ravenphpscripts.com
PHP KISSQ PHP Stock Quote for Standard and phpNuke sites
http://www.ravenphpscripts.com
Jul 17 '05 #1
5 19105
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
Jul 17 '05 #2
gf
"André Nęss" <an*********************@ifi.uio.no> wrote in message
news:bn**********@maud.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?

Gaylen
Raven Web Hosting http://ravenwebhosting.com
PHP KISGB PHP Guest Book for Standard and phpNuke sites
http://www.ravenphpscripts.com
PHP KISSQ PHP Stock Quote for Standard and phpNuke sites
http://www.ravenphpscripts.com
Jul 17 '05 #3
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
http://delusive.dyn.ee
http://sage.dev.box.sk
http://blacksun.box.sk

Jul 17 '05 #4
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: http://zend.com/php/ask_experts.php
(currently fifth question from top).

André Nęss
Jul 17 '05 #5
gf
"John Downey" <bl**@doesntexist.com> wrote in message
news:%t***********************@twister.neo.rr.com. ..
gf wrote:
I had a client recently contact me with a script that wasn't working. Iquickly isolated the problem as to the fact that the $_GET array was notbeing 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
http://delusive.dyn.ee
http://sage.dev.box.sk
http://blacksun.box.sk

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.

--
Gaylen
Raven Web Hosting http://ravenwebhosting.com
PHP KISGB PHP Guest Book for Standard and phpNuke sites
http://www.ravenphpscripts.com
PHP KISSQ PHP Stock Quote for Standard and phpNuke sites
http://www.ravenphpscripts.com
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: billy.becker | last post by:
I need to save a wav file that is HTTP POSTed to a php page. What does PHP5 do automatically to a POSTed variable when it puts it in the $_POST superglobal array? I haven't been able to find any...
15
by: weissborn | last post by:
I'm a php newbie. I have installed apache 2.0.54 and php 5.0.5 on my win2k box. However, it does not appear the php is working properly. I base this on the following code(which I got from a...
2
by: will.lai | last post by:
Hi: Just learning PHP and couldn't get access to the $_POST variables from a form. Here are my code sniplets below. For the life of me I can't figure out why the POST variables aren't being...
9
by: Nicko | last post by:
Hey everyone, I'm on a server running PHP 5.0.5 but we've discovered that there's a problem with it. We cannot create a form with method "POST" because it simply will not post the form data...
3
by: abeb | last post by:
Hi all, I recently given a task to upgrade a running server (PostgreSQL7.3+Apache2.0+PHP4.2) to a new server with PostgreSQL8.1+Apache2.2+PHP5.1 installed (all Fedora Core 6 packages). All is...
7
cassbiz
by: cassbiz | last post by:
the below script worked without any errors before I upgraded to php5 <?php include "cust_logged_in.php"; ?> <script type="text/javascript"> <!-- ...
8
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the...
5
by: The Big One | last post by:
8-7-2008 Hello, Our hosting provider has changed his server to PHP5. I have a PHP file that normaly gives the custumor an email, and i get one mail. Now the server has changed i only get my...
0
by: Jerry Stuckle | last post by:
incredibody@gmail.com wrote: <Lots of code snipped> In their upgrade, they turned off register_globals - which is a good thing. Since you are posting your form, you need to look in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.