Archive for the ‘Uncategorized’ Category

Stale incense, old sweat, and lies, lies, lies

Wednesday, February 2nd, 2011

Superglobals are even more global than you might reasonably expect.

<?php
function foo($_SERVER) {
    /* do nothing */
}
 
foo('oh dear');
var_dump($_SERVER);

This is obviously unreasonable code, but I don’t think anyone would automatically expect that function call to replace the $_SERVER superglobal’s value with the string 'oh dear'.

string(7) "oh dear"

Hat tip to @mark_story.