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

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.

One Response to “Stale incense, old sweat, and lies, lies, lies”

  1. Kit says:

    I think I just threw up a little in my mouth.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped=""> (Syntax highlighting)