php多态
发表于|更新于|php
|浏览量:
通过接口
A有B和C两个实现,但是起实现方法是不同的,这就是PHP多态
文章作者: developer
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Dev!
相关推荐
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 -...
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] +...
2015-09-10
mysql_error
mysql_error() 函数返回上一个 MySQL 操作产生的文本错误信息。本函数返回上一个 MySQL 函数的错误文本,如果没有出错则返回 ‘’(空字符串)。
2015-09-20
php魔术方法__call和__callStatic
__call($name,$arguments)当对象访问不存在时候,__call被调用 __callStatic当对象访问不存在的静态方法时候,__callStatic被调用定义时也要把__callStatic定义为静态方法public static __callStatic($name,$arguments)使用两个点访问静态方法test::runtest();
2015-12-09
mb_strimwidth
按字符宽度获取 mb_strimwidth ( string $str , int $start , int $width [, string $trimmarker [, string $encoding ]] ) 参数说明: $str //指定字符串 $start //指定从何处开始截取 $width //截取文字的宽度 $trimmarker //超过$width数字后显示的字符串 $encoding //设置字符编码【例如:UTF-8】 举个例子来说明 <?php $string=”242432反对感是456犯得上广泛大使馆地方7890”;echo mb_strimwidth($string,0,14,’…’,’UTF-8’);?> 输出的结果就是:242432反对…
2015-09-10
mysql_fetch_row
mysql_fetch_row() 函数从结果集中取得一行作为数字数组。
公告
This is my Blog