Broken multi dimension PHP server variables
29 11 2007At 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.
Categories : PHP
Trackbacks : No Trackbacks »




Trackbacks
No Trackbacks