PHPBuilder - Introduction to PHP5 Page 8



RSS Twitter
Articles Tricks And Hacks

Introduction to PHP5 - Page 8

by: Luis Argerich
|
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).

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Luis Argerich

Comment:



Comment:

(Maximum characters: 1200). You have characters left.