diff --git a/language/namespaces.xml b/language/namespaces.xml index 862ab4973d..24255c39ce 100644 --- a/language/namespaces.xml +++ b/language/namespaces.xml @@ -6,6 +6,7 @@ Namespaces overview + What are namespaces? In the broadest definition namespaces are a way of encapsulating items. This can be seen as an abstract concept in many places. For example, in any @@ -68,13 +69,11 @@ echo constant($d); // see "Namespaces and dynamic language features" section ]]> - - Namespaces are available in PHP as of PHP 5.3.0. - Defining namespaces + Although any valid PHP code can be contained within a namespace, only three type of code are affected by namespaces: classes, functions and constants. @@ -121,6 +120,7 @@ namespace MyProject; // fatal error - namespace must be the first statement in t Declaring sub-namespaces + Much like directories and files, PHP namespaces also contain the ability to specify a hierarchy of namespace names. Thus, a namespace name can be defined with @@ -147,6 +147,7 @@ function connect() { /* ... */ } Defining multiple namespaces in the same file + Multiple namespaces may also be declared in the same file. There are two allowed syntaxes. @@ -261,6 +262,7 @@ echo MyProject\Connection::start(); Using namespaces: Basics + Before discussing the use of namespaces, it is important to understand how PHP knows which namespaced element your code is requesting. A simple analogy can be made @@ -406,6 +408,7 @@ $c = new \Exception('error'); // instantiates global class Exception Namespaces and dynamic language features + PHP's implementation of namespaces is influenced by its dynamic nature as a programming language. Thus, to convert code like the following example into namespaced code: @@ -491,6 +494,7 @@ echo constant('namespacename\constname'), "\n"; // also prints namespaced namespace keyword and __NAMESPACE__ constant + PHP supports two ways of abstractly accessing elements within the current namespace, the __NAMESPACE__ magic constant, and the namespace @@ -585,6 +589,7 @@ $b = namespace\CONSTANT; // assigns value of constant CONSTANT to $b Using namespaces: Aliasing/Importing + The ability to refer to an external fully qualified name with an alias, or importing, is an important feature of namespaces. This is similar to the @@ -721,6 +726,7 @@ class Greenlandic Global space + Without any namespace definition, all class and function definitions are placed into the global space - as it was in PHP before namespaces were @@ -748,6 +754,7 @@ function fopen() { Using namespaces: fallback to global function/constant + Inside a namespace, when PHP encounters a unqualified Name in a class name, function or constant context, it resolves these with different priorities. Class names always @@ -804,6 +811,7 @@ if (is_array('hi')) { // prints "is not array" Name resolution rules + For the purposes of these resolution rules, here are some important definitions: @@ -1004,6 +1012,7 @@ A\B::foo(); // calls method "foo" of class "B" from namespace "A\A" FAQ: things you need to know about namespaces + This FAQ is split into two sections: common questions, and some specifics of implementation that are helpful to understand fully. diff --git a/language/predefined/variables/argc.xml b/language/predefined/variables/argc.xml index f8e724900c..0ed130935a 100644 --- a/language/predefined/variables/argc.xml +++ b/language/predefined/variables/argc.xml @@ -1,7 +1,7 @@ - + $argc The number of arguments passed to script diff --git a/language/predefined/variables/argv.xml b/language/predefined/variables/argv.xml index 456ab90fb3..0d61cbd9c6 100644 --- a/language/predefined/variables/argv.xml +++ b/language/predefined/variables/argv.xml @@ -1,7 +1,7 @@ - + $argv Array of arguments passed to script diff --git a/language/predefined/variables/cookie.xml b/language/predefined/variables/cookie.xml index d833600b42..085b9a449c 100644 --- a/language/predefined/variables/cookie.xml +++ b/language/predefined/variables/cookie.xml @@ -1,7 +1,7 @@ - + $_COOKIE $HTTP_COOKIE_VARS [deprecated] diff --git a/language/predefined/variables/env.xml b/language/predefined/variables/env.xml index cad4f25e1b..050a12cb28 100644 --- a/language/predefined/variables/env.xml +++ b/language/predefined/variables/env.xml @@ -1,7 +1,7 @@ - + $_ENV $HTTP_ENV_VARS [deprecated] diff --git a/language/predefined/variables/files.xml b/language/predefined/variables/files.xml index 3d72100e51..24f15c2ced 100644 --- a/language/predefined/variables/files.xml +++ b/language/predefined/variables/files.xml @@ -1,7 +1,7 @@ - + $_FILES $HTTP_POST_FILES [deprecated] diff --git a/language/predefined/variables/get.xml b/language/predefined/variables/get.xml index 179925d864..5f95b9c70c 100644 --- a/language/predefined/variables/get.xml +++ b/language/predefined/variables/get.xml @@ -1,7 +1,7 @@ - + $_GET $HTTP_GET_VARS [deprecated] diff --git a/language/predefined/variables/globals.xml b/language/predefined/variables/globals.xml index 0998c91e8c..8adef7154a 100644 --- a/language/predefined/variables/globals.xml +++ b/language/predefined/variables/globals.xml @@ -1,7 +1,7 @@ - + $GLOBALS References all variables available in global scope diff --git a/language/predefined/variables/httprawpostdata.xml b/language/predefined/variables/httprawpostdata.xml index 6335392314..082d690cb7 100644 --- a/language/predefined/variables/httprawpostdata.xml +++ b/language/predefined/variables/httprawpostdata.xml @@ -1,7 +1,7 @@ - + $HTTP_RAW_POST_DATA Raw POST data diff --git a/language/predefined/variables/httpresponseheader.xml b/language/predefined/variables/httpresponseheader.xml index 0935e9f3ad..2b5c76e609 100644 --- a/language/predefined/variables/httpresponseheader.xml +++ b/language/predefined/variables/httpresponseheader.xml @@ -1,7 +1,7 @@ - + $http_response_header HTTP response headers diff --git a/language/predefined/variables/phperrormsg.xml b/language/predefined/variables/phperrormsg.xml index 79272189c7..1011a7452e 100644 --- a/language/predefined/variables/phperrormsg.xml +++ b/language/predefined/variables/phperrormsg.xml @@ -1,7 +1,7 @@ - + $php_errormsg The previous error message diff --git a/language/predefined/variables/post.xml b/language/predefined/variables/post.xml index be45babea3..eeb60ce1b3 100644 --- a/language/predefined/variables/post.xml +++ b/language/predefined/variables/post.xml @@ -1,7 +1,7 @@ - + $_POST $HTTP_POST_VARS [deprecated] diff --git a/language/predefined/variables/request.xml b/language/predefined/variables/request.xml index 6ceff4153e..6604694c65 100644 --- a/language/predefined/variables/request.xml +++ b/language/predefined/variables/request.xml @@ -1,7 +1,7 @@ - + $_REQUEST HTTP Request variables diff --git a/language/predefined/variables/server.xml b/language/predefined/variables/server.xml index 99c2c97ef6..a6c7cf819a 100644 --- a/language/predefined/variables/server.xml +++ b/language/predefined/variables/server.xml @@ -1,7 +1,7 @@ - + $_SERVER $HTTP_SERVER_VARS [deprecated] diff --git a/language/predefined/variables/session.xml b/language/predefined/variables/session.xml index bc5fb19e5d..f7ba1fd093 100644 --- a/language/predefined/variables/session.xml +++ b/language/predefined/variables/session.xml @@ -1,7 +1,7 @@ - + $_SESSION $HTTP_SESSION_VARS [deprecated] diff --git a/language/predefined/versions.xml b/language/predefined/versions.xml index bf985b03f9..6db8303204 100644 --- a/language/predefined/versions.xml +++ b/language/predefined/versions.xml @@ -34,6 +34,25 @@ + + + + + + + + + + + + + + + + + + +