面向对象的PHP慢吗? [英] Is object-oriented PHP slow?

查看:62
本文介绍了面向对象的PHP慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用过程样式的PHP.后来,我曾经创建一些类.后来,我学习了Zend Framework,并开始以OOP风格进行编程.现在,我的程序基于我自己的框架(带有cms元素,但没有任何 in 框架),该框架建立在Zend框架的顶部.

I used to use procedural-style PHP. Later, I used to create some classes. Later, I learned Zend Framework and started to program in OOP style. Now my programs are based on my own framework (with elements of cms, but without any design in framework), which is built on the top of the Zend Framework.

现在,它由很多类组成.但是我编程的次数越多,恐怕就越多.恐怕由于这些原因,我的程序会变慢,我恐怕还要再添加一个类,这可以帮助我进行开发,但会使应用程序变慢.

Now it consists of lots classes. But the more I program, more I'm afraid. I'm afraid that my program will be slow because of them I'm afraid to add every another one class which can help me to develop but can slow the application.

我所知道的是,包含大量文件会降低应用程序的速度(使用eAccelerator +将所有代码收集到一个文件中可以使应用程序加速20倍!),但是我不知道是否创建新的类和对象本身会降低PHP的速度.

All I know is that including lots of files slows application (using eAccelerator + gathering all the code in one file can speed up application 20 times!), but I have no idea if creating new classes and objects slows PHP by itself.

有人有关于它的任何信息吗?

Does anyone have any information about it?

推荐答案

此处为轶事基准,它将使OOP PHP开销降低10-15% 我个人认为OOP是更好的选择,因为最终OOP可能会表现得更好,因为它可能经过了更好的设计和考虑.程序代码往往很杂乱且难以维护.因此,最后-必须对您的应用程序的性能差异与维护,扩展和简单理解的能力有多重要

Here's good article discussing the issue. I also have seen some anecdotal bench-marks that will put OOP PHP overhead at 10-15% Personally I think OOP is better choice since at the end it may perform better just because it probably was better designed and thought through. Procedural code tends to be messy and hard to maintain. So at the end - it has to be how critical is performance difference for your app vs. ability to maintain, extend and simply comprehend

这篇关于面向对象的PHP慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆