Re: cvs: php-src / README.namespaces
| From: | Gregory Beaver | Date: | Fri, 17 Aug 2007 18:52:21 +0000 |
| Subject: | Re: cvs: php-src / README.namespaces | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-45922@lists.php.net to get a copy of this message | ||
Hi,
typo alert (inline)
Dmitry Stogov wrote:
> dmitry Fri Aug 17 17:12:29 2007 UTC
>
> Modified files:
> /php-src README.namespaces
> Log:
> Added examples
>
>
>
> http://cvs.php.net/viewvc.cgi/php-src/README.namespaces?r1=1.4&r2=1.5&diff_format=u
> Index: php-src/README.namespaces
> diff -u php-src/README.namespaces:1.4 php-src/README.namespaces:1.5
> --- php-src/README.namespaces:1.4 Thu Aug 2 17:02:41 2007
> +++ php-src/README.namespaces Fri Aug 17 17:12:28 2007
[snip]
> @@ -96,21 +96,74 @@
> 5) unqualified class names are resolved at run-time. E.q. "new Exception()"
> first tries to use (end even __autoload()) class from current namespace and
> in case of failure uses internal PHP class. Note that using "new A" in
> -namespace you can call only create internal PHP class, however using "new
> -::A" you are able to create any class from global namespace
> +namespace you can call only create class from this namespace or
> +internal PHP class, however using "new ::A" you are able to create any class
> +from global namespace
> 6) Calls to qualified functions are resolved at run-time. Call to
> "A::B::foo()" first tries to call function foo() from namespace "A::B",
> then
> it tries to find class "A::B (__autoload() it if necessary) and call its
> -static function foo()
> +static method foo()
> 7) qualified class names are interpreted as class from corresponding
> namespace. So "new A::B::C()" creates class "C" from namespace
> "A::B".
>
> +Examples
> +--------
> +<?php
> +namespace A;
> +foo(); // first tries to call "foo" defined in namespace "A"
> + // then calls internal function "foo"
> +::foo(); // calls function "foo" defined in global scope
> +?>
> +
> +<?php
> +namespace A;
> +new B(); // first tries to create object of class "B" defined in namespace
> "A"
> + // then creates object of internal class "B"
> +new ::B(); // creates object of class "B" defined in global scope
> +?>
> +
> +<?php
> +namespcae A;
> +new A(); // first tries to create object of class "A" from namespace "A"
> (A::A)
> + // then creates object of internal class "A"
s/namespcae/namspace
[snip]
> + - calls to internal functions in namespaces are slower, because PHP first
> + lools for such function in current namespace
s/lools/looks/
Greg