No, you need to make some changes.
namespace My\Own\Namespace; // declare your own namespace use My\ThirdParty\Component; // import 3rd party namespace $component = new Component; // create instance of it var_dump(is_a($component, 'Component')); // FALSE var_dump($component instanceof Component); // TRUE
The is_a and is_subclass_of require the full name of the class (including the namespace) to be specified. As far as I know, this does not happen with PHP 5.3.5. Using instanceof should solve both fundamentals.
Importing your own classes, such as Exception, should also work, for example
namespace My\Own\Namespace; use \Exception as Exception; throw new Exception('something broke');
See the chapter in the namespace in the PHP Manual for more information.
Gordon
source share