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