namespaces seem strange
Posted: Mon Dec 27, 2010 8:16 am
I have a file with the following code:
I get a 'n'.
When I adjust the last line:
now I get a 'y'.
This seems strange, since I declared the namespace at the top of the page. So why do I need to repeat it before I check if the class exists? Adding a "use abc" to indicate I'm using that namespace doesn't seem to help.
Thanks!
Code: Select all
namespace abc;
class widget
{
}
if (class_exists('widget')){echo 'y';} else {echo 'n';}
When I adjust the last line:
Code: Select all
if (class_exists('abc\widget')){echo 'y';} else {echo 'n';}
This seems strange, since I declared the namespace at the top of the page. So why do I need to repeat it before I check if the class exists? Adding a "use abc" to indicate I'm using that namespace doesn't seem to help.
Thanks!