关于我们 广告服务 社区论坛
设为首页 加入收藏

行业新闻
服 务 器
模版下载
建站指南
冲浪宝典
办公软件
网站运营
操作系统
QQ 专题
网页制作
安全防御
视频教程
网络编程
SEO专区
软件下载
图像设计
Cisco
网页特效
Wap 技术
联盟赚钱
网页素材
 首页 | 企业建站 | 网页制作 | 网站运营 | 网络编程 | 图像设计 | 冲浪宝典 | 操作系统 | SEO专区 | 联盟赚钱 | Cisco

欢迎来到e天下网络首页>>网络编程>>PHP>>正文|PHP技巧:优化动态网页技术PHP程序的12条技巧

PHP技巧:优化动态网页技术PHP程序的12条技巧

[ 来路:21kn.com    时间:2007-7-8 14:56:39    点击: ]

 

1、If a method can be static, declare it static. Speed improvement is by a factor of 4.
1、如果一个函数可以声明为静态的,那么就用静态的,速度是改进的一个因素4.

2、# Avoid magic like __get, __set, __autoload
2、避免使用__get, __set, __autoload等魔术函数

3、require_once() is expensive
3、require_once()是相当昂贵的。

4、Use full paths in includes and requires, less time spent on resolving the OS paths.
4、用include和require时,尽量用全路径,可以减少花在解决OS路径的时间

5、If you need to find out the time when the scrīpt started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()
5、如果你需要知道一个脚本的开始运行时间,用 $_SERVER[’REQUEST_TIME’]比用time()要好


6、See if you can use strncasecmp, strpbrk and stripos instead of regex
6、如果可以用strncasecmp, strpbrk and stripos就别用正则

7、preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4
7、preg_replace比str_replace要快,但是strtr比preg_replace更快

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.
一些函数,比如字符串替换函数,接受数组和单个字符做为参数,并且如果你的参数列表不是很长,考虑写一些冗余替换语句,每次传送一个字符,代替一行代码接受数组做为查找和替换的参数。

9、Error suppression with @ is very slow.
9、禁止错误输出符号@是非常慢的。

10、$row[’id’] is 7 times faster than $row[id]
10、、$row[’id’]比 $row[id]快7倍

11、Error messages are expensive
11、错误信息是非常昂贵的

12、Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.
12、不要在循环内部使用函数,比如: for ($x=0; $x < count($array); $x)。count()函数在每次循环中都会被调用。

对于模板,你是否在用smarty?这可能是保证把最经常访问的页面缓存起来的最快的方法了。

::::站长友情提示:多花一分钟学点什么都好::::

 

上一篇:动态网页技术PHP程序中包含文件问题  下一篇:常用技巧:用PHP控制您的浏览器cache

 ::热点信息::

 

= = 免责声明 = =

① 欢迎转载我网所刊信息,请注明“来源:E天下网络”。
② 凡本网注明“来源:XXX(非E天下网络)”的作品,均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如因作品内容、版权和其它问题需要同本网联系的,请在30日内进行。
※联系方式:Airtofly@163.com

::推荐文章::

 

ASP教程:详细学习ASP的内置对象

::图像设计::

 

动态图片搜索家——GIF RUNN
软件搜索利器——FileFerret
实例说明构图要讲规律
Character Builder让你尽展靓
全景图速成者Cool360
三维模型速成工具——Canoma
剪贴专家SmartBoard 32
新世纪的图像处理利器——Ph
更多内容..

 

 

关于我们 广告服务 友情链接 合作伙伴 社区论坛 免责声明

Copyright © 2007   21kn.com Inc. All rights reserved.e天下网络工作室

网站白天客服QQ:26875416 (非24小时)  合作QQ:597004688    粤ICP备06026423号