<?php
class person
{
private $name;
private $sex;
private $age;
function __construct($name="张三",$sex="",$age=90)
{
$this->name=$name;
$this->sex=$sex;
$this->age=$age;
}
function say()
{
echo"这个人在说话<br>";
}
function run()
{
echo"这个人在走路<br>";
}
function __clone()
{
$this->name="我是".$this->name."副本";
$this->age=20;
}
function info()
{
echo"我的名字是:".$this->name." 性别:".$this->sex." 年龄:".$this->age."<br>";
}
function __call($na,$ar)
{
echo"你所调用的函数".$na."(参数";
print_r($ar);
echo")不存在<br>";
}
function __destruct()
{
echo"再见".$this->name."<br>";
}
}
$te=new person("张三",'男',50);
$te->info();
$tn=clone $te;
$te->info();
$tn->info();
$te->func("sdkfh",2,3);
?>
克隆与错误处理
最新推荐文章于 2020-04-29 17:07:09 发布