如何通过interface的使用说明.php实现高效编程?
- 内容介绍
- 文章标签
- 相关推荐
本文共计147个文字,预计阅读时间需要1分钟。
phpinterface User { // 定义用户类型接口}
class Goods { var $price=100; var $vc;
function run($vc) { $this->vc=$vc; }}
function getUserType() { return VIP用户;}
interface的使用和说明.phpdiscount; } function getUserType(){ return "VIP用户"; } } //商品类 class Goods{ var $price = 100; var $vc; //定义 User 接口类型参数,这时并不知道是什么用户 function run($vc){ $this->vc = $vc; $discount = $this->vc->getDiscount(); $usertype = $this->vc->getUserType(); echo $usertype."商品价格:".$this->price*$discount; } } //调用案例 $Goods = new Goods(); $Goods->run(new VipUser); ?>
本文共计147个文字,预计阅读时间需要1分钟。
phpinterface User { // 定义用户类型接口}
class Goods { var $price=100; var $vc;
function run($vc) { $this->vc=$vc; }}
function getUserType() { return VIP用户;}
interface的使用和说明.phpdiscount; } function getUserType(){ return "VIP用户"; } } //商品类 class Goods{ var $price = 100; var $vc; //定义 User 接口类型参数,这时并不知道是什么用户 function run($vc){ $this->vc = $vc; $discount = $this->vc->getDiscount(); $usertype = $this->vc->getUserType(); echo $usertype."商品价格:".$this->price*$discount; } } //调用案例 $Goods = new Goods(); $Goods->run(new VipUser); ?>

