Home Tutorial Php Phpoop PHP OOP Namespace

 
 

Share on Google+Share on Google+
PHP OOP Namespace
Posted on: February 26, 2010 at 12:00 AM
Advertisement
The term namespace is very much common in OOP based language, basically it is a collection of classes, objects and functions. Namespace is one of the major change in PHP 5.3.0. Naming collision of classes, functions and variables can be avoided.

Namespace in PHP:

The term namespace is very much common in OOP based language, basically it is a collection of classes, objects and functions.

Namespaces are one of the major change in PHP 5.3.0. Naming collision of classes, functions and variables can be avoided.

We can put any code of PHP within a namespace, but in general class, functions, and constants are placed for easy identification and retrieval. 

A namespace is declared with namespace keyword, but we should keep remember that namespace is introduced in PHP 5.3.0 and if we try this in older version of PHP then a error message would appear. The namespace should always declare on the top of the page.

PHP OOP Namespace Example:

<?php

namespace MyProject;

?>

Exaplanation:

We should declare the namespace as above and we can also place a backslash between multiple names of namespace.

 

 

 

 

Advertisement

Related Tags for PHP OOP Namespace:


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.

Posted on: February 26, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com