Share on Google+Share on Google+

Sub Namespace

In this tutorial we will study about sub namespace in PHP, how to declare namespace in PHP, how to access etc. Examples will make this clearer.

Declaring sub-namespace:

We all are familiar with the directory structure or the tree of the file and folders, similarly we can get the nested or sub namespaces in PHP, this technique helps us to achieve more manageability. If you have done Java or C# before then this topic will be more easier.

The following example is illustrating the concept of this topic, no output will be generated.



namespace mySpace\FirstLevel\SecondLevel;

function myFunction()


echo __FUNCTION__;


class One


function myMethod()


echo __METHOD__;






Posted on: April 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.