RE: [PHP-DEV] Simple Namespace Proposal
| From: | Dmitry Stogov | Date: | Tue, 10 Jul 2007 06:12:36 +0000 |
| Subject: | RE: [PHP-DEV] Simple Namespace Proposal | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-30718@lists.php.net to get a copy of this message | ||
Hi Derick,
Your example will work fine.
I made a mistake in my sentence. I meant not "multiple files in namespace"
but "multiple namespaces in file".
Proposed concept allows multiple files in namespace but not multiple
namespaces in file.
Thanks. Dmitry.
> -----Original Message-----
> From: Derick Rethans [mailto:derick@php.net]
> Sent: Monday, July 09, 2007 10:38 PM
> To: Dmitry Stogov
> Cc: 'Larry Garfield'; internals@lists.php.net
> Subject: RE: [PHP-DEV] Simple Namespace Proposal
>
>
> On Sun, 8 Jul 2007, Dmitry Stogov wrote:
>
> > Note that multiple files in namespace won't allow autoloading.
>
> That got me confused a bit. I was wondering whether the
> following would
> work (with autoload):
>
>
> In file "a/b.php":
>
> <?php
> namespace a;
> class b { }
> ?>
>
> in file "a/c.php":
>
> <?php
> namespace a;
> class c { }
> ?>
>
> In file "a/d.php":
>
> <?php
> namespace a;
> class d { }
> ?>
>
> in file "a/e.php":
>
> <?php
> namespace a;
> class e { }
> ?>
>
>
>
> in "index.php":
>
> <?php
> function __autoload( $className )
> {
> include str_replace( "::", "/", $className ) . ".php";
> }
>
> $b = new a::b;
> $c = new a::c;
>
> import a;
>
> $d = new d;
> $e = new e;
>
> ?>
>
>
> regards,
> Derick
>
> --
> Derick Rethans
> http://derickrethans.nl |
> http://ez.no | http://xdebug.org
>