php优化代码的方式

WBOY
Release: 2016-06-23 13:38:14
Original
1006 people have browsed it


1.使用zend optimizer
方法在php.ini添加
zend_optimization_level=15
zned_extendsion="path/to/zendOptimizer.so"
zend_loader.enable=off


注意只有当不适用zend Enocder Runtime 的时候才能把zend_loader关掉


最后一行的作用:不执行zend_loader可以稍微加快Opimizer的速度。


2.使用缓存(程序规模很大)
Zend cache,  Afterburner Cache,  apc


3.网页压缩内容
gzip压缩网页


4.小技巧:
用i +=1 代替 i = i+1;
尽可能使用PHP内部函数
能使用单引号的字符串时尽量使用单引号字符串
foreach代替while遍历数组

数据库方面:
提高数据库的性能
升级服务器或者建一个负载平衡环境
不要小看内容压缩的作用

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!