Home Backend Development PHP Tutorial Why is PHP so annoying for large systems_PHP Tutorial

Why is PHP so annoying for large systems_PHP Tutorial

Jul 13, 2016 pm 05:19 PM
php Why Large develop I use system

I have been working on PHP application development for the past four years. PHP is really easy to write. But PHP also has some very serious flaws.

Below I will give my reasons why PHP is not suitable for websites larger than small amateur websites.

1. Poor support for recursion
Recursion is a mechanism by which a function calls itself. This is a powerful feature that can turn something complex into something very simple. An example of using recursion is quicksort). Unfortunately, PHP is not very good at recursion. Zeev, a PHP developer, said: "PHP 4.0Zend) uses a stack approach for dense data rather than a heap approach. This means that the number of recursive functions it can tolerate is significantly less limited than other languages." See bug 1901. This is a very bad excuse. Every programming language should provide good recursion support.

2. Many PHP modules are not thread-safe
A few years ago, Apache released version 2.0 of the web server. This version supports multi-threading mode, in which one part of the software can run multiple parts at the same time. The inventor of PHP says that the core of PHP is thread-safe, but non-core modules may not be. But nine times out of ten, you want to use this module in a PHP script, but this makes your script incompatible with Apache's multi-threaded mode. This is why the PHP team does not recommend running PHP in Apache 2's multi-threaded mode. PHP's poor multi-threaded mode support is often cited as one of the reasons why Apache 2 remains unpopular.

3. PHP is crippled by commercial applications
By using caching, PHP performance can be increased by 500% [see benchmark]. So why isn't caching built into PHP? Because Zend, the maker of PHP, sells its own Zend Accelerator, so of course they don't want to ditch their commercial product.

But there is another alternative: APC. Zend later launched Zend Optimizer, a free accelerator - Translator)

4. No namespace
Imagine someone made a PHP module to read files. One function in the module is called read. Then another person's module can read the web page, which also contains a function read. Then we can't use these two modules at the same time, because PHP doesn't know which function you want to use.

But there is a very simple solution, and that is namespaces. Someone once suggested adding this feature to PHP5, but unfortunately he did not do so. Now, without namespaces, each function must be prefixed with the module name to avoid name conflicts. This results in horribly long function names, such as xsl_xsltprocessor_transform_to_xml, which makes the code difficult to write and understand.

5. Non-standard date format characters
Many programmers are familiar with date format characters, which come from UNIX and C languages. Several other programming languages ​​have adopted this standard, but strangely enough, PHP has its own set of completely incompatible date format characters. In C, "%j" represents the day of the year, and in PHP it represents the day of the month. However, to make matters even more confusing, the strftime and date_format functions of Smarty (a popular PHP template engine) use C/UNIX formatting characters.

6. Confusing licenses
You may think that PHP is free, and all PHP modules mentioned in the manual are also free. Wrong! For example, if you want to generate PDF files in PHP, you will find two modules in the manual: PDF and ClibPDF. But both of these are commercially licensed. So, for every module you use, you have to make sure you agree to its license.

7. Inconsistent function naming rules
Some function names are composed of multiple words. There are generally three habits of word combinations:

Direct splicing: getnumberoffiles
Separate with underscores: get_number_of_files
Camel's rule: getNumberOfFiles
For most languages, choose one of them. But PHP is used.

For example, if you want to convert some special characters into HTML entities, you would use the function htmlentities to directly concatenate words). If you want to use the opposite functionality, you need to use its little brother html_entity_decode. For some special reason, this function name has words separated by underscores. How could this be? You know there is a function called strpad. Or is he str_pad? Every time you have to check what the symbol is or wait for an error. Functions are case-insensitive, so for PHP there is no difference between rawurldecode and RawUrlDecode. This is also bad because both are used and they look different, confusing the reader.

8. Magic quote hell
Magic quote) can protect PHP scripts from SQL injection attacks. This is good. But for some reasons, you can turn off this configuration in php.ini. So if you want to write a flexible script, you always need to check whether magic references are on or off. Such a "feature" is supposed to make programming easier, but in fact it makes it more complicated.

9. Lack of standard framework
A growing website without an overall framework will eventually become a maintenance nightmare. A framework can make many tasks easier. The most popular framework model now is the MVC-model, in which the presentation layer, business logic and database access are separated.

Many PHP websites do not use the MVC-model. They don't even have a frame. Even now there are some PHP frameworks and you can write one yourself. The articles and manuals about PHP do not improve the framework a word. While JSP-developers use frameworks like Struts and ASP developers use .Net, it seems like these concepts are widely understood by PHP developers. This shows how professional PHP actually is.

Summary: What’s the problem?

For very small projects, it can be a very satisfactory programming language. But for larger and more complex projects, PHP shows its weakness. As you keep exploring, you will find solutions to some of the problems I mentioned. So, once the solution is known, why not fix it? Also why aren't these fixes mentioned in the manual?

It is a good thing that an open source language is very popular. Unfortunately, it's not a great language. I hope all problems can be solved one day maybe in PHP6? ), then we will have an open source language that is both open source and easy to use.

As of now, when you want to start a project with more than 5 script pages, you'd better consider C#/ASP.Net or Java/JSP or maybe Python is also a better choice.

After I wrote this article, some people told me about other similar articles:
Experiences of Using PHP in Large Websites
"PHP in contrast to Perl"
I hate PHP
PHP Annoyances


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/589777.htmlTechArticleI have been working on the development of PHP applications for the past four years. PHP is really easy to write. But PHP also has some very serious flaws. Below I will give my reasons why PH...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

Does H5 page production require continuous maintenance? Does H5 page production require continuous maintenance? Apr 05, 2025 pm 11:27 PM

The H5 page needs to be maintained continuously, because of factors such as code vulnerabilities, browser compatibility, performance optimization, security updates and user experience improvements. Effective maintenance methods include establishing a complete testing system, using version control tools, regularly monitoring page performance, collecting user feedback and formulating maintenance plans.

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

What are the advantages of H5 page production What are the advantages of H5 page production Apr 05, 2025 pm 11:48 PM

The advantages of H5 page production include: lightweight experience, fast loading speed, and improving user retention. Cross-platform compatibility, no need to adapt to different platforms, improving development efficiency. Flexibility and dynamic updates, no audit required, making it easier to modify and update content. Cost-effective, lower development costs than native apps.

What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? Apr 07, 2025 am 12:02 AM

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

Can JS run without H5? Can JS run without H5? Apr 06, 2025 am 09:06 AM

Is JavaScript available to run without HTML5? The JavaScript engine itself can run independently. Running JavaScript in a browser environment depends on HTML5 because it provides the standardized environment required to load and execute code. The APIs and features provided by HTML5 are crucial to modern JavaScript frameworks and libraries. Without HTML5 environments, many JavaScript features are difficult to implement or cannot be implemented.

Describe the purpose and usage of the ... (splat) operator in PHP function arguments and array unpacking. Describe the purpose and usage of the ... (splat) operator in PHP function arguments and array unpacking. Apr 06, 2025 am 12:07 AM

The... (splat) operator in PHP is used to unpack function parameters and arrays, improving code simplicity and efficiency. 1) Function parameter unpacking: Pass the array element as a parameter to the function. 2) Array unpacking: Unpack an array into another array or as a function parameter.

How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) Apr 08, 2025 am 12:03 AM

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

See all articles