Re: Re: namespace separator and whining

From: Date: Mon, 27 Oct 2008 02:51:10 +0000
Subject: Re: Re: namespace separator and whining
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-41411@lists.php.net to get a copy of this message
On Sun, 2008-10-26 at 21:46 -0500, Greg Beaver wrote: > Robert Cummings wrote: > > On Mon, 2008-10-27 at 09:28 +1030, Andrew Mason wrote: > >> So can I just confirm that what was previously > >> > >> <?php > >> > >> $x = new Framework::Utils::Foo(); > >> $y = new Project::PEAR::Bar( 'somestring' ); > >> > >> > >> ?> > >> > >> is now > >> > >> <?php > >> > >> $x = new Framework\Utils\Foo(); > >> $y = new Project\PEAR\Bar( 'somestring' ); > >> > >> ?> > >> > >> > >> Is this correct ? > > > > Wouldn't it be: > > > > <?php > > > > $x = new Framework\Utils::Foo(); > > $y = new Project\PEAR::Bar( 'somestring' ); > > ?> > > The correct syntax is: > > <?php > // initialize class > $a = new Framework\Utils\Foo(); > // namespaced function > Framework\Utils\parse($string); > // static method > Project\PEAR\XML::makeEntity('\\'); > // namespaced constant > if ($a == Framework\Utils\FOO) echo "hi"; > // class constant > if ($a == Project\PEAR\XML::ZOMG) echo "bye"; > ?> > > Note that static class elements are accessed using T_DOUBLE_COLON (::), > and that the namespace separator \ is used to join namespace and element > name. Sorry, my mistake, I didn't notice the 'new' contsruct. Sorry for the pollution. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.internals (#41411) next »