您的位置:首页 > 编程语言 > PHP开发

php 接口继承接口

2011-12-28 11:00 387 查看
<?php
interface User
{
function getName();
function setName($_name);
}
interface VipUser extends User //VipUser继承User接口
{
function getDiscount(); //此处添加了一个抽象的方法
}
class Vip implements VipUser
{
private $name;
private $discount = 0.8; //折扣变量
function getName() {
return $this->name;
}
function setName($_name) {
$this->name = $_name;
}
function getDiscount() {
return $this->discount;
}
}

$v = new Vip;
echo $v->getDiscount();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: