Home > Article > Backend Development > Why is php not suitable for large projects?
# Why is php not suitable for large projects?
1. Poor support for recursion
Recursion is a mechanism for functions to call themselves. 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.0 (Zend) 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 not sound due to business reasons
By using cache, the performance of PHP can be increased by 500% [see benchmark test]. 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 option: APC. (Zend later launched Zend Optimizer, a free accelerator - Translator)
4, is not standard The date format character
Many programmers are familiar with the date format character, which comes from UNIX and the C language. 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 things even more confusing: Smarty (a popular PHP template engine)'s strftime function and date_format function use C/UNIX formatting characters.
5. Confusing License
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.
6. Inconsistent function naming rules
Some function names are composed of multiple words. There are generally three habits of word combinations:
● Direct splicing: getnumberoffiles
● Separated by underscores: get_number_of_files
● Camel's rule: getNumberOfFiles
Most of them Choose one of the languages. But PHP is used.
For example, if you want to convert some special characters into HTML entities, you would use the function htmlentities (directly splicing 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 just 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.
7. The hell of magic quotes
Magic quotes 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.
Summary
For very small projects, it can be a very satisfactory programming language. But for larger and more complex projects, PHP shows its weakness.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of Why is php not suitable for large projects?. For more information, please follow other related articles on the PHP Chinese website!