FANDOM


NamespaceEdit

  • use backslash, instead of "." as Java, to separate namespace levels
  • global namespace "\"
PHP Java

Simple format:

namespace MyNameSpace\subns;
// class declaration ...

Bracket format:

namespace MyNameSpace2 {
// class declaration ...
}

Global namespace:

namespace {
// class declaration ...
}
  • applicable to class, function and constant
package MyNameSpace.subns;

Import or aliasing namespace:

use MyNameSpace\subns as SubLevel;
SubLevel/func1();

use MyNameSpace\subns;
subns/func1()
import MyNameSpace.subns.*;
Community content is available under CC-BY-SA unless otherwise noted.