php魔术方法__tostring __invoke
发表于|更新于|php
__tostring
当对象被当作string使用时,这个方法被调用
__invoke
当对象被当作方法调用时,这个方法被调用
文章作者: developer
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Dev!
相关推荐
2015-09-20
php魔术方法 __clone
当你使用clone关键字时,__clone 就会触发
2015-09-11
魔术方法__call
如果你试着调用一个对象中不存在的方法,__call 方法将会被自动调用。
2015-09-20
php魔术方法__call和__callStatic
__call($name,$arguments)当对象访问不存在时候,__call被调用 __callStatic当对象访问不存在的静态方法时候,__callStatic被调用定义时也要把__callStatic定义为静态方法public static __callStatic($name,$arguments)使用两个点访问静态方法test::runtest();
2018-07-01
php array_walk array_map
效率对比可以选用array_walk array_map foreach for 产生数组12$max = 100000;$arr = range(0, $max); for0.0202569961547850.0197999477386470.020244121551514[ 12345678// for$temp = 0;$t1 = microtime(true);for ($i = 0; $i < $max; $i++){ callback($arr[$i]);}$t2 = microtime(true); foreach0.0171449184417720.0175659656524660.02012300491333 1234567$temp=0;$t1 = microtime(true);foreach ($arr as $value) { callback($value);}$t2 = microtime(true);echo $t2 - $t1; array_walk0.02513313293457...
2018-07-10
php trait
Trait中的方法或属性会覆盖基类(如果有继承关系)中的同名的方法或属性,而本类会覆盖Trait中同名的方法,如果本类或基类和Trait有同名属性会冲突报错 基本定义和class很像。Trait基本定义如下 123456trait Dog{ public $name="dog"; public function bark(){ echo "This is dog"; }} 基本使用只要在类里use之后,就可以使用Trait里的方法 123456class Cat extends Animal{ use Dog; public function drive(){ echo "This is cat drive"; }} 与当前类同名trait很像继承,所以当当前类与trait类方法同名时候,当前类会覆盖trait方法 123456789101112131415161718tra...
2017-09-02
php apache 配置 https ssl phpstudy 开启 Forward Secrecy 前向保密
SSL HTTPS检测获得A+的方法 检测地址 https://www.ssllabs.com/ssltest/ apache版本 2.4 开启php的openssl模块 开启apache的ssl模块 一般大家是用apache虚拟机的增加如下配置 1234567891011121314151617181920212223242526272829Listen 443<VirtualHost *:443> DocumentRoot "C:\php\www" ServerName iguojin.com ServerAlias # 开启HSTS长期有效 Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" # 开启SSL SSLEngine on # 添加SSL协议支持协议 SSLProtocol all -SSLv2 -SSLv3 # 服务器...
公告
This is my Blog