优化php
看了40 Tips for optimizing your php code
摘几条,这些都是以前从来没有想到,或者改变起来代价很小的,顺手翻译一下:
Use echo’s multiple parameters instead of string concatenation.
使用echo的多重参数,而不用字符串连接符号(译注:简言之就是用,代替.作为echo的连接符)
require_once() is expensive
require_once()的开销很大(译注:我都是使用这个来避免文件的重复载入……)
See if you can use strncasecmp, strpbrk and stripos instead of regex
用strncasecmp,strpbrk或者stripos这些函数代替正则
str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4
str_replace函数比preg_replace函数快,但strtr函数的效率是str_replace函数的四倍
Error suppression with @ is very slow.
用@屏蔽错误消息很慢
$row[’id’] is 7 times faster than $row[id]
$row['id']的速度是$row[id]的7倍
分布式的版本管理 » « 你的xp“系统资源不足,无法完成api”吗
相关文章
- No Related Posts