批改状态:合格
老师批语:
命名空间一:
namespace one
{
class Demo{public $name='hyman';}
const SITE='深圳';
function add($a,$b){return $a+$b;}
}命名空间二:
namespace two
{
class Demo1{public $name='程序员';}
const SITE='民治';
function add($a,$b){return $a+$b;}
}__NAMESPACE__ 函数可查看当前的属于空间
命名空间的引入可用use,例如在namespace one 中导入two空间中的Demo如下语法:
use two\Demo as Demo1;
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号