加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

PHP技巧 优化动态网页技术PHP程序的8条方法

发布时间:2022-03-11 07:42:42 所属栏目:编程 来源:互联网
导读:1、如果一个函数可以声明为静态的,那么就用静态的,速度是改进的一个因素4。 2、# Avoid magic like __get, __set, __autoload 3、require_once() is expensive 4、Use full paths in includes and requires, less time spent on resolving the OS paths. 5
 
  1、如果一个函数可以声明为静态的,那么就用静态的,速度是改进的一个因素4。
 
 
  2、# Avoid magic like __get, __set, __autoload
 
 
  3、require_once() is expensive
 
  4、Use full paths in includes and requires, less time spent on resolving the OS paths.
 
 
  5、If you need to find out the time when the scrīpt started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()
 
 
  6、See if you can use strncasecmp, strpbrk and stripos instead of regex
 
  7、preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4
 
 
 
  8、If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.
 
  一些函数,比如字符串替换函数,接受数组和单个字符做为参数,并且如果你的参数列表不是很长,考虑写一些冗余替换语句,每次传送一个字符,代替一行代码接受数组做为查找和替换的参数。
 
 
  对于模板,你是否在用smarty?这可能是保证把最经常访问的页面缓存起来的最快的方法了。

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读