What happens here, is that PHP sees a constant called test
. If the constant is defined, the value is returned, it isn't defined, PHP falls back to the string "test"
. For example:
$array = array("A" => "Foo", "B" => "Bar", "C" => "Baz")
define("B", "C");
echo $array[A]; // The constant "A" is undefined,
// so PHP falls back to the string "A",
// which has the value "Foo".
echo $array["B"]; // The result is "Bar".
echo $array[B]; // The value of constant "B" is the string "C".
// The result is "Baz".
It's for backwards compatibility and you should never use it. If you'll turn on notices, you'll see that PHP complains about it.