(1) __clone方法在一个对象赋值给另外的一个对象的时候自动调用

<?php

class A
{
	public $a = "aa";
	public $b = 10;
	function __clone()
	{
		$this->a = "bb";
		$this->b = 2;
	}
	function __toString()
	{
		return $this->a."{$this->b}";
	}
}
$a= new A();
$b = clone $a;
echo $b; //输出 bb2

  

(2)__call 当调用的类成员函数不存在的时候自动调用

<?php

class A
{
	public $a = "aa";
	public $b = 10;
	function __clone()
	{
		$this->a = "bb";
		$this->b = 2;
	}
	function __toString()
	{
		return $this->a."{$this->b}";
	}
	function __call($method,$args)
	{
		echo "调用的方法{$method}()不存在,参数是:";
		print_r($args);;

	}
}
$a= new A();
$a->aa(1,2);

如果是静态方法,会自动调用__callStatic函数

最新文章

  1. dev c++ Boost库的安装
  2. JSON与JSONP
  3. sockopt note
  4. c++读入之 -- 汉字读入遇到的问题
  5. 安装SqlServer2008时相关问题
  6. 使用NPOI导出,读取EXCEL(可追加功能)
  7. 不想作死系列---virtualbox最小化安装centos6.5
  8. Netty 4源码解析:服务端启动
  9. Notepad++编写运行python程序
  10. 更新本地git仓库的远程地址(remote地址)
  11. V4L2应用程序框架【转】
  12. Android DatePickerDialog 使用方法
  13. node-rsa
  14. AngularJS 模块及provide
  15. NXP LPC-Link LPC3154
  16. 配置Oracle E-Business Suite Integrated SOA Gateway Release 12.1.2/12.1.3
  17. ZOJ 2083 Win the Game(SG函数)题解
  18. zbrush书法文字硬边雕刻
  19. 采集baidu搜索信息的java源代码实现(大部分转发,少量自己修改)(使用了htmlunit和Jsoup)(转发:https://blog.csdn.net/zhaohang_1/article/details/44731039)
  20. thinkphp函数学习(1)——header, get_magic_quotes_gpc, array_map, stripslashes, stripslashes_deep

热门文章

  1. 1013. Battle Over Cities
  2. 用SignalR实现实时查看WebAPI请求日志
  3. A little bit about Handlers in JAX-WS
  4. WPF感悟
  5. [Java] Java解析XML格式Response后组装成Map
  6. //解决validator验证插件多个name相同只验证第一的问题
  7. meta 360极速模式
  8. JAVA字符串05之课程问题解决
  9. cocos2d-x的CCAffineTransform相关变换实现原理
  10. UI测试 错题分析