How to use "root" namespace of php?

Viewed 22005

I have an Exception class:

namespace abc;

class AbcException extends Exception {
// blah blah
}

It produces this error:

Class 'abc\Exception' not found ...

Questions:

  1. What can I do to make this work ?

  2. Useful documents are appreciated.

Thanks for reading my question

5 Answers

Under windows you don't need the leading \ to denote the root namespace. Once you deploy to a *nix environment you will have to explicitly add the \ in front of the class name whenever you use it or put the use statement for each root namespace class you are using before you use them, otherwise you'll get a class not found fatal error.

Related