Reputation: 3
Relative newbie to php, running into an issue with namespaces. Inside my own class within a custom namespace I am trying to call the native php ReflectionClass, but it is telling me that it can not find it within my own namespace. How do I call the global ReflectionClass?
$reflectedNode = new ReflectionClass($obj);
Thanks in advance.
Upvotes: 0
Views: 160
Reputation: 31651
Prefix your name with a "\", like so:
$reflectedNode = new \ReflectionClass($obj);
Read the manual.
Upvotes: 1
Reputation: 28346
The PHP documentation has an FAQ that covers this:
http://www.php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.globalclass
Essentially you just prefix the global class name with a backslash (\) character.
Upvotes: 1