Variables in namespaces are global!
2009 April 11
This surprised me:
namespace foo
{
$foo = 'foo';
}
namespace bar
{
echo $foo; // foo
}
I was looking for a way to import a namespace variable inside a function in the same namespace and the only way I found was to use global $foo; inside the function, which I thought was defeating the whole purpose of namespaces. Then I found out that there’s no such thing as namespace variables! That makes me feel less guilty about using global, but that’s still retarded.