RE: [PHP-DEV] Simple Namespace Proposal

From: Date: Mon, 09 Jul 2007 18:38:04 +0000
Subject: RE: [PHP-DEV] Simple Namespace Proposal
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-30688@lists.php.net to get a copy of this message
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

« previous php.internals (#30688) next »