RE: [PHP-DEV] Namespace

From: Date: Sat, 08 Dec 2007 22:09:26 +0000
Subject: RE: [PHP-DEV] Namespace
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-33876@lists.php.net to get a copy of this message
Quick question... If I wanted to override or extend php's functions... Could this work? Say I want to change the implementation of var_dump() to make it more html friendly... function var_dump($mixedVariable) { echo('<pre>'); ::var_dump($mixedVariable); echo('</pre>'); } SCOTT MCNAUGHT Software Developer Synergy 8 / +617 3397 5212 scott.mcnaught@synergy8.com -----Original Message----- From: Sam Barrow [mailto:sam@sambarrow.com] Sent: Sunday, 9 December 2007 7:23 AM To: RQuadling@GoogleMail.com Cc: Lokrain; internals@lists.php.net Subject: Re: [PHP-DEV] Namespace Once you say "namespace xyz ;" everything in the file is now relative to namespace xyz. To refer to the global namespace, you use the following <?php namespace xyz ; function substr() { return true ; } substr(); // calls substr in current namespace ::substr(); // calls substr in global namespace ?> On Sat, 2007-12-08 at 20:12 +0000, Richard Quadling wrote: > On 07/12/2007, Lokrain <lokrain@gmail.com> wrote: > > Hello all, > > > > I just wanted to drop an opp. Just to see the logic, when we have > > programming structure class, interface, function, if statement, switch > > statement etc, we have bracers encapsulation. This is the logic that most > > programming language give to show a programmer that something is inside > > something. We here have namespace with the same idea, and no bracers. > > > > Conclusion: namespaces are not logical => no thanks > > > > PS. By the way, I do not think that any workarounds on that logic will not > > be nice. > > > > I'm trying to understand the argument against using braces. > > And that has led me to the following question. > > Assuming no braces, how would I put code OUTSIDE of the namespace in a > single file. > > <?php > namespace XYZ; > > xyz related code goes here > > non xyz related code goes here but how do I let PHP know it isn't part of xyz? > > > > Do I have to change namespace by using a dummy namespace? Same issue > how do I refer to the global namespace. > > > Richard. > > -- > ----- > Richard Quadling > Zend Certified Engineer : > http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.internals (#33876) next »