ネームスペースの利点はこれだと思っている。
複数人で開発とかしているときに関数名やクラスなどが
かぶってしまう可能性ある、そういうのを
解決してくれるのがネームスペースということです。
<?php
namespace testdemo;
class test{
function demo():string
{
return "demo1n";
}
}
namespace testdemo2;
class test{
function demo():string
{
return "demo2n";
}
}
<?php
include_once "./index-6.php";
$demo = new testdemotest();
print $demo->demo();
$demo = new testdemo2test();
print $demo->demo();