Reputation: 57
Since yesterday I am going to use namespaces in php and I have a little problem there:
namespace NamespaceName;
use StdClass;
$s = new StdClass;
$s->meow = "Hello World";
echo $s->meow;
Is there any way that I must not include the "use StdClass"?
Upvotes: 1
Views: 35
Reputation: 59681
You just have to put a backspace in your declaration, so that you use StdClass from the global namespace:
$s = new \StdClass;
//^ See here
Upvotes: 1