Home > Article > Backend Development > Why is Php performance poor?
Common reasons that affect PHP performance
1.php itself uses improper grammar
2.php is not good at it period () (recommended learning: PHP programming from entry to proficiency)
3.php's surrounding environment (server Linux, disk: file storage, database, cache: memory, network: Bandwidth)
4.php’s own shortcomings
5. Unknown issues
Analysis
PHP code execution Process
*.php(PHP文件)->Scanner(扫描代码,分析)->Exprs(保存成zend引擎可以识别的文件)->Parser(解析)->Opcodes(能被执行的文件)->Exec(执行)->Output(输出结果)
php language-level performance optimization. Refers to the basic functions of PHP syntax. This part of optimization is relatively simple, easy to see, fast and feasible, and the effect can be seen relatively quickly.
Write less PHP code and use PHP's own capabilities to solve problems
性能问题 自写代码冗余较多,可读性不佳,并且性能低,如代码很长很长...PHP代码越长PHP的执行效率越慢。 为什么性能低? PHP代码需要解析编译为C语言,底层C语言又要编译成汇编语言机器语言才能执行,这个过程在每次请求过来之后都要处理一遍,所以 开销很大(项目变大的话...)。 解决方法: 多使用PHP内置的变量、常量、函数。我们用PHP代码实现的功能和使用PHP内置的函数实现的同样功能差别是有的。
The performance advantages and disadvantages of PHP's built-in functions.
情况描述 PHP内置函数之间依然存在快慢差别;少用PHP魔术方法; 建议: 多去了解PHP内置函数的执行实现复杂度。 测试方法:比较效率测试,如用microtime()函数,取差值,精确到毫秒级别;Linux的time命令可以查看开销。
The above is the detailed content of Why is Php performance poor?. For more information, please follow other related articles on the PHP Chinese website!