PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Lorna Mitchell's Blog: 3 Ways to Access a Namespaced PHP Class

Note: This article was originally published at PHPDeveloper on 30 November 2010.
PHPDeveloper

Lorna Mitchell has posted three different ways you can use to get access to a namespaced class in a PHP 5.3 application, all useful depending on where you are in the application and your needs.

After what felt like years of debate over the notation to use for PHP's namespaces, it seems like the feature itself has had relatively little use or attention since it was actually implemented in PHP 5.3. We're all used to working without it but using it does make code neater.

Her three options are:

  • Refer Namespace and Class Name
  • Import the Namespace
  • Alias the Namespace and/or Class

You can find out more about namespaces in PHP applications on the PHP manual.