php 7.2 双问号,php 7.2 一些注意事项.

48304ba5e6f9fe08f3fa1abda7d326ab.png

each 函数 在php7.2已经设定为过时,<?phpcount ('');// Warning:  count(): Parameter must be an array or an object that implements Countable

count 函数在php7.2将严格执行类型区分.  不正确的类型传入, 会引发一段警告.

48304ba5e6f9fe08f3fa1abda7d326ab.png<?php $newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');echo "New anonymous function: $newfunc\n";echo $newfunc(2, M_E) . "\n";// outputs

// New anonymous function: lambda_1

// ln(2) + ln(2.718281828459) = 1.6931471805599

// Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

48304ba5e6f9fe08f3fa1abda7d326ab.png

create_function 函数在php7.2已经设定为过时.

-----------------------------------------------------------------------------------------------------------

解决方法:

48304ba5e6f9fe08f3fa1abda7d326ab.pngfunction fun_adm_each(&$array){   $res = array();   $key = key($array);   if($key !== null){       next($array); 

$res[1] = $res['value'] = $array[$key];       $res[0] = $res['key'] = $key;

}else{       $res = false;

}   return $res;

}

48304ba5e6f9fe08f3fa1abda7d326ab.png

替代each.

48304ba5e6f9fe08f3fa1abda7d326ab.pngfunction fun_adm_count($array_or_countable,$mode = COUNT_NORMAL){    if(is_array($array_or_countable) || is_object($array_or_countable)){        return count($array_or_countable, $mode);

}else{        return 0;

}

}

48304ba5e6f9fe08f3fa1abda7d326ab.png

替代count.

替代create_function.

END

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值