Namespace

Normally PHP does not allowed to use same multiple class name or method. So what you do on that situation. You can use Namespace. Namespace just like a virtual directory. You can use same multiple class name or method without a name collision.


/* first.php */
<?php

class A{

	function __construct(){

		echo "I am at global space </br>";
	}
}

/* second.php */
<?php

namespace second;

class A{

	function __construct(){

		echo "I am at second space <br/>";
	}
}


/* index.php */
<?php

include "first.php";
include "second.php";

use second\A;

//$obj = new second\A;	// qualified class name

$obj = new A;		// unqualified class name

$obj = new \A;		// fully qualified class name