#namespace_test_1.php
<?php
namespace namespace_test_1;
class test
{
const NAMESPACE = 'namespace_test_1';
public static function run()
{
echo self::NAMESPACE.PHP_EOL;
}
?>
#namespace_test_2.php
<?php
namespace namespce_test_2;
class test
{
const NAMESPACE = 'namespace_test_2';
public static function run()
{
echo self::NAMESPACE.PHP_EOL;
}
}
?>
#namespace_test_3.php
<?php
namespace namespace_test_3;
use namespace_test_1 as name_1;
use namespace_test_2 as name_2;
!class_exist('namespace_test_1\test') && require './namespace_test_1.php';
!class_exist('namespace_test_2\test') && requeire './namespace_test_2.php';
class test
{
const NAMESPCE = 'namespace_test_3';
public static function run()
{
echo self::NAMESPACE.PHP_EOL;
}
}
name_1\test::run(); //namespace_test_1
name_2\test::run(); //namespace_test_2
test::run(); //namespace_test_3
?>