Blogger Information
Blog 26
fans 1
comment 0
visits 19209
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
类的 继承
坏人也温柔de陈词滥调
Original
792 people have browsed it

实例

<?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();   
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:常量命名不规范,推荐全大写,下次要注意
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post