cvs: ZendEngine2 / ZEND_CHANGES

From: Date: Thu, 07 Mar 2002 10:31:51 +0000
Subject: cvs: ZendEngine2 / ZEND_CHANGES
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6@lists.php.net to get a copy of this message
sebastian Thu Mar 7 05:31:51 2002 EDT Modified files: /ZendEngine2 ZEND_CHANGES Log: Add another 'import' example and merge 'import' section into 'Namespaces' section. Index: ZendEngine2/ZEND_CHANGES diff -u ZendEngine2/ZEND_CHANGES:1.20 ZendEngine2/ZEND_CHANGES:1.21 --- ZendEngine2/ZEND_CHANGES:1.20 Sat Mar 2 17:26:17 2002 +++ ZendEngine2/ZEND_CHANGES Thu Mar 7 05:31:51 2002 @@ -160,8 +160,7 @@ defaulting to the current global one. The current namespace may be changed on a file-by-file basis. Symbols in other namespaces than the current one may be referenced using a new namespace - operator. It is possible to "import" symbols from one namespace - into another. + operator. Namespaces and classes are the same with the Zend Engine 2.0, except that you can't instantiate a namespace with "new". This @@ -256,36 +255,53 @@ This prints "foobar" two times, since a bar() method exists in the current namespace. - Old code that does not take advantage of namespaces will run - without modifications. + * It is possible to "import" symbols from one namespace into + another. + + Example: + + <?php + class MyClass { + function hello() { + print "Hello, World\n"; + } + + class MyClass2 { + function hello() { + print "Hello, World in MyClass2\n"; + } + } + } - * import statement. + import function hello, class MyClass2 from MyClass; - With the new import statement it is possible to import classes - and methods from other classes (namespaces) to the current scope. + MyClass2::hello(); + hello(); + ?> - Example: + Example: - <?php - class MyClass { - function hello() { - print "Hello, World\n"; - } + <?php + class MyOuterClass { + class MyInnerClass { + function func1() { + print "func1()\n"; + } - class MyClass2 { - function hello() { - print "Hello, World in MyClass2\n"; + function func2() { + print "func2()\n"; + } + } } - } - } - import function hello, class MyClass2 from MyClass; + import class * from MyOuterClass; + import function func2 from MyOuterClass::MyInnerClass; - MyClass2::hello(); - hello(); - ?> + MyInnerClass::func1(); + func2(); + ?> - Old code that has no user-defined function 'import' will run + Old code that does not take advantage of namespaces will run without modifications. * Unified Constructors.

« previous php.zend-engine.cvs (#6) next »