Correcting teacher:查无此人
Correction status:qualified
Teacher's comments:完成的不错,继续加油。
<?php
//创建类
class demo{
}
//调用类/实例化
$d1 = new demo();
$d2 = new demo();
var_dump($d1);
var_dump($d2);
var_dump($d1 instanceof demo);
//类属性
class demo1{
public $a ='aa';
public $s = 111;
}
$aa = new demo1;
echo $aa->a . $aa->s;
echo '<hr>属性重新赋值';
$aa->s = 222;
echo $aa->a . $aa->s;
//行为(方法)
class demo2 {
// //属性
public $name = 'WJF';
public $mail= '33703259@qq.com';
// //方法
function test1 (){
//self:当前类
$dangqian = new self();
//$this 伪变量 引用当前类中的实例
return '姓名:' . $dangqian->name . '邮箱:' . $this->mail;
}
}
$d2 = new demo2();
echo $d2->test1();
<?php
//创建类
class Demo{
//属性
public $a;
public $s;
//构造方法
function __construct($a,$s)
{
$this->a = $a;
$this->s = $s;
}
//方法
function tset(){
echo $this->a;
}
}
$obj = new Demo('啊啊啊',333);
echo $obj->tset();