Broken multi dimension PHP server variables

29 11 2007

At The First Post we have several development environments all with different configurations. Now with this setup it is really easy to overwrite one configuration file by accident (it has never happened but you get the idea). Now with Apache you can use the SetEnv command to set variables (more like constants) which can be picked up by the $_SERVER superglobal.

I thought it would be an interesting experiment to find out what would happen if you tried to create an array using SetEnv, for example:

SetEnv MY_ARRAY[] 'first element'
SetEnv MY_ARRAY[] 'second element'

I tested this on a VM using Apache 2.0.52 and PHP 5.1.6, the results were really surprising, at first it worked! Then it didn't… WTF happened there then???

It turns out that the first time an Apache processes was used it worked, the second time the same process was used the first element was showing only as a variable rather than an array. I haven't figured out if this is a bug in Apache or if the fact you can do it at all is a bug in Apache. Either way I just stuck to standard SetEnv for the conclusion for the tests.


Bookmark Broken multi dimension PHP server variables  at del.icio.us Digg Broken multi dimension PHP server variables

Trackbacks


No Trackbacks

Comments

Display comments as (Linear | Threaded)
No comments

Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA