2018-11-23 12:57

造一个类型,并且再造一个该类型的变量(即:对象):

<?php
header('Content-type:text/html;charset=utf-8');

class Ghost{
	public $name="聂小倩";
	public $age=23;
	public $addr="兰若寺";

	public function show(){
		echo "姓名:{$this->name}<br />";
		echo "年龄:{$this->age}岁<br />";
		echo "地址:{$this->addr}<br />";
	}
}

$g=new Ghost();
$g->show();