Namespace Flashcards

1
Q

Namespace syntax (2)

A
  1. namespace Foo\Bar
  2. namespace Foo\Bar {
    }// To mix namespace in a single file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Mixing namespaced and non-namespaced code in a file

A
namespace Foo\Bar {
//Namespaced code
}
namespace {
//Non-namespaced code
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Accessing current namespace of subnamespace (2)

A

namespace\Foo\Bar;

__NAMESPACE__\Foo\Bar;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Import a namespaced class A with name B from namespace Foo\Bar

A

use Foo\Bar\A as B;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Import a namespaced function a() with name b() from namespace Foo\Bar

A

use function Foo\Bar\a as b;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Import a namespaced constant A with name B from namespace Foo\Bar

A

use const Foo\Bar\A as B;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Fallback use undefined function in namespace

A

Try in namespace, if not exist, try in global space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly