Sub Namespace
Posted on: April 1, 2010 at 12:00 AM
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.

Example:

<?php

namespace mySpace\FirstLevel\SecondLevel;

function myFunction()

{

echo __FUNCTION__;

}

class One

{

function myMethod()

{

echo __METHOD__;

}

}

 

?>

Related Tags for Sub Namespace:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.