Can anyone explain why the below code causes a "Cannot find class" error? Instantiating the class with the fully qualified name works, but eliminates the advantage of the "use" statement.
<?php
namespace
{
use Foo\Bar;
new Bar; // Works
$class = 'Foo\Bar';
new $class; // Works
$class = 'Bar';
new $class; // "Cannot find class" error
}
namespace Foo
{
class Bar {}
}
Thanks