Correction status:Uncorrected
Teacher's comments:
<?php //命名空间 namespace one { //导入one\two的命名空间 另命名 use one\two\Demo as Demo1; class Demo { public $name='小红帽'; } //常量 const TITLE = '童话故事'; //add方法 function add($a,$b) { return $a+$b; } //输出Demo echo (new Demo)->name; //输出two\Demo echo (new Demo1)->name; } namespace one\two { class Demo { public $name='小蓝帽'; } const TITLE = '格林童话'; function add($a,$b) { return $a+$b; } }
点击 "运行实例" 按钮查看在线实例