Namespace Flashcards
1
Q
Namespace syntax (2)
A
- namespace Foo\Bar
- namespace Foo\Bar {
}// To mix namespace in a single file
2
Q
Mixing namespaced and non-namespaced code in a file
A
namespace Foo\Bar { //Namespaced code } namespace { //Non-namespaced code }
3
Q
Accessing current namespace of subnamespace (2)
A
namespace\Foo\Bar;
__NAMESPACE__\Foo\Bar;
4
Q
Import a namespaced class A with name B from namespace Foo\Bar
A
use Foo\Bar\A as B;
5
Q
Import a namespaced function a() with name b() from namespace Foo\Bar
A
use function Foo\Bar\a as b;
6
Q
Import a namespaced constant A with name B from namespace Foo\Bar
A
use const Foo\Bar\A as B;
7
Q
Fallback use undefined function in namespace
A
Try in namespace, if not exist, try in global space