php执行效率相关的语句

2020-12-13 05:57

阅读:256

标签:style   blog   class   c   code   http   

一:字符替换:

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执行效率相关的语句,搜素材,soscw.com

php执行效率相关的语句

标签:style   blog   class   c   code   http   

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


评论


亲,登录后才可以留言!