News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen's Blog:
A primer on PHP namespaces
February 16, 2012 @ 08:25:43

For those that either haven't worked much with PHP 5.3 in their applications (or just haven't gotten around to using the feature) Rob Allen has put together an introduction to namespaces to guide you through some first steps and share some example usage.

I know that there are a lot of posts now about namespaces in PHP 5.3. This is mine which is how I learnt how they work. [...] That is, namespaces allow us to: combine libraries with the same classnames, avoid very long classnames and organise our code easily. Note that namespaces do not just affect classes. They also affect functions and constants.

He starts with the basic namespace definition (using the "namespace" keyword), shows how to import another namespace with "use" and the use of the __NAMESPACE__ constant to determine what namespace you're operating in. More information on namespaces can be found in the PHP manual.

0 comments voice your opinion now!
namespace introduction tutorial constant use


blog comments powered by Disqus

Similar Posts

Chance Garcia's Blog: MAMP PRO, PECL, SSH2, and OSX CLI (AKA acronym madness)

SitePoint PHP Blog: Building a Web App With Symfony 2: Development

SitePoint PHP Blog: Message Queues: Comparing Beanstalkd, IronMQ and Amazon SQS

MaltBlue.com: Zend Framework 2 Forms - Simple and Available Everywhere

Zend Developer Zone: Implementing a Stemming Analyzer for Zend_Search_Lucene


Community Events

Don't see your event here?
Let us know!


example voicesoftheelephpant application opinion podcast api extension framework version release series performance php7 interview symfony2 laravel library testing introduction community

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework