类和对象定义及使用
<?php
// 类
class Person{
// 属性
public $name;
public $age;
// 构造方法
public function __construct($n,$a){
$this->name=$n;
$this->age=$a;
}
// 方法
public function say(){
echo "my name is {$this->name},my age is {$this->age} ";
}
}
$obj=new Person('uers1',10);
$obj->say();
**
my name is uers1,my age is 10