批改状态:合格
老师批语:常量命名不规范,推荐全大写,下次要注意
<?php
//命名空间
namespace first;//第一个命名空间
const a=1;
function test()
{
echo '我是第一个命名空间'.'<br/>';
}
namespace second;//第二个命名空间
const a=2;
function test()
{
echo '我是第二个命名空间'.'<br/>';
}
test(); //打印出 我是第二个命名空间
echo a.'<br/>';点击 "运行实例" 按钮查看在线实例
< ?php
class a{
public $x;
public $y;
function __construct($x=0,$y=0){
$this->x=$x;
$this->y=$y;
}
function getx(){
return $this->x;
}
function gety(){
return $this->y;
}
function __destruct(){}
}
class a2 extends a{}
/*extends是一个继承函数*/
$b2=new a2(10,10);
echo $b2->getx()."<br>";
echo $b2->gety();
?>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号