|
|
|
@ -293,54 +293,6 @@ Changes in the Zend Engine 2.0 |
|
|
|
print $obj->address . "\n"; |
|
|
|
?> |
|
|
|
|
|
|
|
* Namespaces. |
|
|
|
|
|
|
|
The Zend Engine 1.0 provided only three scopes: the global |
|
|
|
scope, the class scope and the function scope. All scopes but |
|
|
|
classes could contain variables, only the class and global |
|
|
|
scopes could contain functions, while only the global scope |
|
|
|
could contain constants and classes. This means that all of the |
|
|
|
Zend Engine 1.0's scoping methods were inherently limited for |
|
|
|
solving symbol name collision problems. |
|
|
|
|
|
|
|
The Zend Engine 2.0 introduces the concept of namespaces |
|
|
|
to solve the symbol collision problem by making it possible to |
|
|
|
define multiple symbol tables able to contain all types of |
|
|
|
symbols. |
|
|
|
|
|
|
|
A namespace may contain classes, constants, functions and variables. |
|
|
|
The member of a namespace is accessed by prefixing its name with the |
|
|
|
name of the namespace followed by '::'. |
|
|
|
|
|
|
|
Example: |
|
|
|
|
|
|
|
<?php |
|
|
|
namespace Foo { |
|
|
|
class Bar {} |
|
|
|
const aConstant = 'someValue'; |
|
|
|
function aFunction() {} |
|
|
|
var $aVariable; |
|
|
|
} |
|
|
|
|
|
|
|
$o = new Foo::Bar; |
|
|
|
echo Foo::aConstant; |
|
|
|
Foo::aFunction(); |
|
|
|
Foo::$aVariable = 'someValue'; |
|
|
|
?> |
|
|
|
|
|
|
|
A namespace's name may contain colons to denote "sub-namespaces". |
|
|
|
This is pure syntactic sugar, the Zend Engine will not see, for |
|
|
|
instance, the namespaces "Package", "Package:Subpackage" and |
|
|
|
"Package:Subpackage:Subsubpackage" as related. |
|
|
|
|
|
|
|
Namespaces can be neither nested nor instantiated. |
|
|
|
|
|
|
|
To avoid ambiguities in the '::' resolution there may be no |
|
|
|
global class and namespace with the same name. |
|
|
|
|
|
|
|
Old code that has no user-defined classes or functions named |
|
|
|
'namespace' should run without modifications. |
|
|
|
|
|
|
|
* Unified Constructors. |
|
|
|
|
|
|
|
The Zend Engine allows developers to declare constructor methods |
|
|
|
@ -428,8 +380,7 @@ Changes in the Zend Engine 2.0 |
|
|
|
|
|
|
|
* Constants. |
|
|
|
|
|
|
|
The Zend Engine 2.0 introduces per-class and per-namespace |
|
|
|
constants. |
|
|
|
The Zend Engine 2.0 introduces per-class constants. |
|
|
|
|
|
|
|
Example: |
|
|
|
|
|
|
|
|