#native_company# #native_desc#
#native_cta#

Introduction to PHP5 Page 8

By Luis Argerich
on April 11, 2003

Namespaces

Namespaces can be used to group classes or functions for convenience.
Example 14: Namespaces

<?php

namespace Math 
{

  class Complex {

    
//...code...

    
function __construct() {

      print(
"hey");

    }

  }

}

$m = new Math::Complex();

?>



Note how namespaces can be used to qualify the class that should be created. As a practical example
you may want to declare the same class name in different namespaces to do different things (but
with the same interface).

1
|
2
|
3
|
4
|
5
|
6
|
7
|
8