Reputation: 3809
I'm using a pear library that doesn't utilize namespaces and some composer based libraries which, obviously, do. I'd like to use namespaces in my own code, but I find that when I import classes from the pear library (non-namespaced) I can't reference them correctly.
<?php namespace Foo\Bar;
require_once "pearLib/Baz.php";
class MyClass extends Baz { ... }
PHP looks for the class Foo\Bar\Baz
, giving me the message The Class 'Foo\Bar\DataType' not found
. I simply want the non-namespaced Baz
class which I just imported. Suggestions???
Upvotes: 4
Views: 1446
Reputation: 31137
To get it off the unanswered list:
Use a backslash before the class name like:
class MyClass extends \Baz
Upvotes: 1