php - How to use namespaces in non space classes? -
Is there a way to use namespace classes in non-namespace classes?
Example:
// Note, class A and B. have no namespace ... extension of class A B {public functions () {$ obj = new My \ Namespace \ SomeObject (); Return $ obj; }} Thank you.
Just use the operator:
or you can use a fully qualified name, eg:
$ obj = new \ My \ Namespace \ SomeObject () ; Pay attention to the major backslash. Contained namespace, because in fact there is no non-nomenclature):
-
No requires a leading backslash. - Using
namespace is a syntax error because it does not matter in a reserved word (case is PHP because class, method and function Many keywords with names are case-insensitive). - Using
do is a syntax error, as it is also a reserved word ( do / while control Structure).
Comments
Post a Comment