首页 > Web开发 > 详细

php执行效率相关的语句

时间:2014-05-21 23:40:18      阅读:515      评论:0      收藏:0      [点我收藏+]

一:字符替换:

strtr > str_replace > preg_replace

注意:

1:一般用strtr函数的这种形式:string strtr ( string $str , array $replace_pairs )

2:如果 replace_pairs 中包含一个空 字符串 "")键,那么将返回 FALSE 。 If the str is not a scalar then it is not typecasted into a string, instead a warning is raised and NULL is returned.

//note this output null
echo strtr(‘abc‘, array(‘‘ => ‘‘));

 

参考:http://blog.csdn.net/aidenliu/article/details/5695433

 

二:对数组中的每个单元作用函数时用array_map,他的性能大于循环数组使用对应的函数处理

如:
$integers
= array_map (‘intval‘, $integers);
$safeStrings = array_map (‘mysql_real_escape_string‘, $unsafeStrings);
$_POST
= array_map(‘strip_tags‘, $_POST);

 

 

 

php执行效率相关的语句,布布扣,bubuko.com

php执行效率相关的语句

原文:http://www.cnblogs.com/Alight/p/3738999.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!