Blogger Information
Blog 25
fans 2
comment 0
visits 18568
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php教学-命名空间,类与对象,构造方法_11.28
果莫个人博客
Original
643 people have browsed it

命名空间

namespace  admin;
class Demo{
//属性
public $product ;
public $price ;
function __construct($product,$price)
   {
   $this ->product =$product;
   $this ->price =$price ;
   }
   //自定义方法
   public function getInfo(){
   return ‘品名:’.$this ->product.’,价格:’.$this ->price ;
   }
}
//实例化
$demo = new Demo (‘小米手机’,3500);
echo $demo ->getInfo();

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:二点问题, 第一,代码不要用纯文本, 应该放在代码块中提交, 第二你的键盘很棒... 还有, markdown语法, 你们老师教过, 作业 尽可能用它来写, 代码关键字能高亮, 便于查阅// 你的博客并不是只有老师看, 全国全世界网友都可以看到的
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