NYCPHP Meetup

NYPHP.org

[nycphp-talk] Namespaces

Tim Gales tgales at tgaconnect.com
Thu Jan 10 13:21:28 EST 2008


David Krings wrote:
> Hi!
> 
> I got sucked into a (probably pointless) discussion about ASP vs. PHP. 
> One of the arguments against using PHP was that there is only a single 
> namespace. Uhm, that took the wind out of my sail as I have no clue what 
> a namespace is and why having only one is really bad.
> 
> Anyone can explain that to me in laymen terms?

The meaning of an identifier, such as a variable or a function name,
can depend on where it is mentioned in the program.

(for an example about variables see:
http://www.php.net/manual/en/language.variables.scope.php)

Sometimes it is difficult for a language's compiler or interpreter
to distinguish between two identifiers with the same name.
In other words, when two identifiers are in the same scope and have
the same name, they clash.

Some computer languages have keywords which produce namespaces.
Differing namespaces can be used to resolve (i.e. distinguish)
variables, functions, etc. which have the same name.

(see:
http://en.wikipedia.org/wiki/Namespace_%28programming%29
for more)

-- 

T. Gales & Associates
'Helping People Connect with Technology'

http://www.tgaconnect.com



More information about the talk mailing list