NYCPHP Meetup

NYPHP.org

[nycphp-talk] A Cautionary Tale & then a question...

Chris Snyder csnyder at chxo.com
Fri Sep 5 11:30:48 EDT 2003


Waitaminit!

What if the version of PHP on the new server didn't support $_REQUEST? 
And had register_globals turned on?
I think you might get those results, then, eh?


Jeff Knight wrote:

> I recently had to move one of my php sites from one server to another 
> and learned (once again) that not all php servers are the same (give 
> me a break, I've had a hangover for about three days now (or is it 
> four?)). One of the things that most attracted me to php after working 
> with asp for so long was its lenience towards doing things on-the-fly 
> without a lot of set up and declarations, etc. So I had some old code 
> that worked on my 1st server:
>
>     if ($_REQUEST['from']) {
>         $from['rgb'] = $_REQUEST['from'];
>     } else {
>         $from['rgb'] = '000000';
>     }
>     if ($_REQUEST['to']) {
>         $to['rgb'] = $_REQUEST['to'];
>     } else {
>         $to['rgb'] = 'FFFFFF';
>     }
>     
>     echo "to: $to<BR>";
>     echo "to[rgb]: {$to['rgb']}<BR>";
>     
>     echo "from: $from<BR>";
>     echo "from[rgb]: {$from['rgb']}<BR>";
>
> Which produced the output:
>     to: Array
>     to[rgb]: FFFFFF
>     from: Array
>     from[rgb]: 000000
>
> When I moved the code to a new server, the results were:
>     to: FFFFFF
>     to[rgb]: F
>     from: 4563456
>     from[rgb]: 4
>
> Of course, none of this was immediately obvious, since the code was 
> inside a php script that generated a png and had no echo statements. 
> Of course I should've originally said
>
>     $from = array( 'rgb' => '000000');
>
> But I'm lazy.
>
> I am a little curious about what setting in php.ini allows this 
> behavior on my (development) server though, since I suppose I should 
> turn it off so it matches with the outside world.
>
>
>
>
>
> Jeff Knight
> jeff at lushmedia.com
> 212/213-6558 x 203
> LUSH media
> 110 W 40th St #1502
> New York, NY 10018
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk





More information about the talk mailing list