克隆与错误处理

来源:互联网 发布:阿里云服务器宕机原因 编辑:程序博客网 时间:2024/06/15 01:14
<?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);?>

 
原创粉丝点击