language/namespaces.xml
d4d5216e7a965ca194f6b1c9dee84cecab2674e5
...
...
@@ -6,6 +6,7 @@
6
6

7
7
<sect1 xml:id="language.namespaces.rationale">
8
8
<title>Namespaces overview</title>
9
+
<titleabbrev>Overview</titleabbrev>
9
10
<?phpdoc print-version-for="namespaces"?>
10
11
<simpara>
11
12
What are namespaces? In the broadest definition namespaces are a way of encapsulating
...
...
@@ -86,6 +87,7 @@ echo constant($d); // see "Namespaces and dynamic language features" section
86
87

87
88
<sect1 xml:id="language.namespaces.definition">
88
89
<title>Defining namespaces</title>
90
+
<titleabbrev>Namespaces</titleabbrev>
89
91
<?phpdoc print-version-for="namespaces"?>
90
92
<para>
91
93
Although any valid PHP code can be contained within a namespace, only the following
...
...
@@ -139,6 +141,7 @@ namespace MyProject; // fatal error - namespace must be the first statement in t
139
141
</sect1>
140
142
<sect1 xml:id="language.namespaces.nested">
141
143
<title>Declaring sub-namespaces</title>
144
+
<titleabbrev>Sub-namespaces</titleabbrev>
142
145
<?phpdoc print-version-for="namespaces"?>
143
146
<para>
144
147
Much like directories and files, PHP namespaces also contain the ability to specify
...
...
@@ -166,6 +169,7 @@ function connect() { /* ... */ }
166
169
</sect1>
167
170
<sect1 xml:id="language.namespaces.definitionmultiple">
168
171
<title>Defining multiple namespaces in the same file</title>
172
+
<titleabbrev>Defining multiple namespaces in the same file</titleabbrev>
169
173
<?phpdoc print-version-for="namespaces"?>
170
174
<para>
171
175
Multiple namespaces may also be declared in the same file. There are two allowed
...
...
@@ -281,6 +285,7 @@ echo MyProject\Connection::start();
281
285
</sect1>
282
286
<sect1 xml:id="language.namespaces.basics">
283
287
<title>Using namespaces: Basics</title>
288
+
<titleabbrev>Basics</titleabbrev>
284
289
<?phpdoc print-version-for="namespaces"?>
285
290
<para>
286
291
Before discussing the use of namespaces, it is important to understand how PHP
...
...
@@ -404,7 +409,7 @@ echo \Foo\Bar\FOO; // resolves to constant Foo\Bar\FOO
404
409
Note that to access any global
405
410
class, function or constant, a fully qualified name can be used, such as
406
411
<function>\strlen</function> or <classname>\Exception</classname> or
407
-
<literal>\INI_ALL</literal>.
412
+
\<constant>INI_ALL</constant>.
408
413
<example>
409
414
<title>Accessing global classes, functions and constants from within a namespace</title>
410
415
<programlisting role="php">
...
...
@@ -427,6 +432,7 @@ $c = new \Exception('error'); // instantiates global class Exception
427
432
</sect1>
428
433
<sect1 xml:id="language.namespaces.dynamic">
429
434
<title>Namespaces and dynamic language features</title>
435
+
<titleabbrev>Namespaces and dynamic language features</titleabbrev>
430
436
<?phpdoc print-version-for="namespaces"?>
431
437
<para>
432
438
PHP's implementation of namespaces is influenced by its dynamic nature as a programming
...
...
@@ -504,7 +510,8 @@ echo constant('namespacename\constname'), "\n"; // also prints namespaced
504
510
</para>
505
511
</sect1>
506
512
<sect1 xml:id="language.namespaces.nsconstants">
507
-
<title>namespace keyword and __NAMESPACE__ constant</title>
513
+
<title>The namespace keyword and __NAMESPACE__ magic constant</title>
514
+
<titleabbrev>namespace keyword and __NAMESPACE__</titleabbrev>
508
515
<?phpdoc print-version-for="namespaces"?>
509
516
<para>
510
517
PHP supports two ways of abstractly accessing elements within the current namespace,
...
...
@@ -601,6 +608,7 @@ $b = namespace\CONSTANT; // assigns value of constant CONSTANT to $b
601
608

602
609
<sect1 xml:id="language.namespaces.importing">
603
610
<title>Using namespaces: Aliasing/Importing</title>
611
+
<titleabbrev>Aliasing and Importing</titleabbrev>
604
612
<?phpdoc print-version-for="namespaces"?>
605
613
<para>
606
614
The ability to refer to an external fully qualified name with an alias, or importing,
...
...
@@ -778,6 +786,7 @@ use const some\namespace\{ConstA, ConstB, ConstC};
778
786
</sect1>
779
787
<sect1 xml:id="language.namespaces.global">
780
788
<title>Global space</title>
789
+
<titleabbrev>Global space</titleabbrev>
781
790
<?phpdoc print-version-for="namespaces"?>
782
791
<para>
783
792
Without any namespace definition, all class and function definitions are
...
...
@@ -805,7 +814,8 @@ function fopen() {
805
814
</para>
806
815
</sect1>
807
816
<sect1 xml:id="language.namespaces.fallback">
808
-
<title>Using namespaces: fallback to global function/constant</title>
817
+
<title>Using namespaces: fallback to the global space for functions and constants</title>
818
+
<titleabbrev>Fallback to global space</titleabbrev>
809
819
<?phpdoc print-version-for="namespaces"?>
810
820
<para>
811
821
Inside a namespace, when PHP encounters an unqualified Name in a class name, function or
...
...
@@ -863,6 +873,7 @@ if (is_array('hi')) { // prints "is not array"
863
873

864
874
<sect1 xml:id="language.namespaces.rules">
865
875
<title>Name resolution rules</title>
876
+
<titleabbrev>Name resolution rules</titleabbrev>
866
877
<?phpdoc print-version-for="namespaces"?>
867
878
<para>
868
879
For the purposes of these resolution rules, here are some important definitions:
...
...
@@ -1049,6 +1060,7 @@ A\B::foo(); // calls method "foo" of class "B" from namespace "A\A"
1049
1060
</sect1>
1050
1061
<sect1 xml:id="language.namespaces.faq">
1051
1062
<title>FAQ: things you need to know about namespaces</title>
1063
+
<titleabbrev>FAQ</titleabbrev>
1052
1064
<?phpdoc print-version-for="namespaces"?>
1053
1065
<para>
1054
1066
This FAQ is split into two sections: common questions, and some specifics of
1055
1067