php多态
发表于|更新于|php
通过接口
A有B和C两个实现,但是起实现方法是不同的,这就是PHP多态
文章作者: developer
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Dev!
相关推荐
2019-04-30
斐波那契数列 php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960// 递归$len = 20;function f($a){ if ($a == 1 || $a == 2) { return 1; } return f($a-1) + f($a-2);}var_dump(f($len));// 数组function test($num){ $arr = []; for ($i = 0; $i < $num; $i++) { if ($i == 0 || $i == 1) { $arr[$i] = 1; } else { $arr[$i] = $arr[$i - 1] +...
2017-09-11
php strtotime 常用要点
strtotime 是个常用的函数一般是获取当前时间 手册中是他的语义化的用法 1strtotime("+2 day" ,time())
2015-09-11
register_shutdown_function
来源 http://yanue.net/post-99.html 1、当页面被用户强制停止时 2、当程序代码运行超时时 3、当PHP代码执行完成时,代码执行存在异常和错误、警告 1,register_shutdown_function()函数可重复调用,但执行的顺序与注册的顺序相同2,如果在调用register_shutdown_function()函数之前有exit()函数调用,register_shutdown_function()函数将不能执行3,PHP4后支持注册函数参数传递4,在某些服务端,如Apache,当前目录在register_shutdown_function()函数中能够改变5,register_shutdown_function()函数执行在headers发送之后 register_shutdown_function(array(“test”)); register_shutdown_function(array($this, “f”)); 运行结果:(运行顺序和注册顺序一样)beforehellof():hello
2019-09-05
PHP 获取 对象唯一id spl_object_hash
1234567// 对象spl_object_hash测试$object = new stdClass;$id = spl_object_hash($object);var_dump($id); // 00000000408de7e4000000006ad86d42$object->id = 1;$id = spl_object_hash($object);var_dump($id); // 00000000408de7e4000000006ad86d42 注意When an object is destroyed, its hash may be reused for other objects.当对象被销毁时候,这个哈希id可能被其他对象重用
2019-08-30
php SplQueue php标准库 队列 和数组 性能差异
数组模拟队列12345678910111213141516171819$t1 = microtime(true);$arrq = array();for ($i = 0; $i < 100000; $i++) { $data = "hello $i\n"; array_push($arrq, $data); if ($i % 100 == 99 and count($arrq) > 100) { $popN = rand(10, 99); for ($j = 0; $j < $popN; $j++) { array_shift($arrq); } }}$popN = count($arrq);for ($j = 0; $j < $popN; $j++) { array_shift($arrq);}$t2 = microtime(true);echo ($t2 -...
2015-12-07
php mb_regex_encoding
mb_regex_encoding — 设置/获得 多字节正则表达式 字符编码 如:中文
公告
This is my Blog