gender,"\r\n" ;}}class family{public $people;public $location;public function __construct($p,$loc){">
当前位置:Gxlcms > PHP教程 > php实例-对象与类

php实例-对象与类

时间:2021-07-01 10:21:17 帮助过:18人阅读

name,"\tis",$this->gender,"\r\n" ;
		}
	}
	
	class family{
		public $people;
		public $location;
		public function __construct($p,$loc){               //显示声明一个构造方法且带参数
			$this->people = $p;
			$this->location = $loc;
		}
	}
	
	
	$student = new person();
	$student -> name = 'Tom';
	$student -> gender = 'male';
	$student -> say();
	$tom = new family($student,'peking');
	echo serialize($student);
	$student_arr = array('name'=>'Tom','gender'=>'male');
	echo "\n";
	echo serialize($student_arr);
	print_r($tom);
	echo "\n";
	echo serialize($tom);
?>

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了php实例-对象与类,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行