In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what are the very serious defects based on PHP, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Poor support for recursion
Recursion is a mechanism by which a function calls itself. This is a powerful feature that can make something complex very simple. One example of using recursion is quick sorting (quicksort). Unfortunately, PHP is not good at recursion. Zeev, a PHP developer, said: "PHP 4.0 (Zend) uses a stack instead of a heap for dense data. This means that it can tolerate a significantly less limit on the number of recursive functions than other languages." See bug 1901. This is a very bad excuse. Every programming language should provide good recursion support.
two。 Many PHP modules are not thread safe
A few years ago, Apache released version 2.0 of the Web server. This version supports multithreaded mode, in which one part of the software can run multiple at the same time. The inventors of PHP say that the core of PHP is thread-safe, but non-core modules are not necessarily. But nine times out of ten, you want to use this module in a PHP script, but this makes your script unsuitable for Apache's multithreaded mode. This is why the PHP team does not recommend running PHP in Apache 2's multithreaded mode. Poor multithreading support makes PHP often considered to be one of the reasons why Apache 2 is still unpopular.
3. PHP is not sound due to commercial reasons.
By using caching, the performance of PHP can soar by 500% [see benchmark]. So why isn't the cache built in PHP? Because the maker of Zend--PHP, it is selling its own Zend Accelerator, so of course, they do not want to abandon their commercial products this piece of fat.
But there is another choice: APC. (Zend later launched Zend Optimizer, a free accelerator.)
4. No namespace
Imagine someone making a PHP module to read files. A 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 both modules at the same time, because PHP doesn't know which function you want to use. But there is a simple solution, and that is namespaces. Someone once suggested that PHP5 add this feature, but unfortunately he didn't do so. Now, there is no namespace, and each function must be prefixed with the module name to avoid name conflicts. This leads to long function names, such as xsl_xsltprocessor_transform_to_XML, which makes the code difficult to write and understand.
5. Non-standard date format character
Many programmers are familiar with date format characters, which are derived from UNIX and C languages. Other programming languages adopt this standard, but oddly enough, PHP has its own set of completely incompatible date format characters. In C, "% j" means the day of the year, and in PHP he means the day of the month. What makes things even more confusing, however, is that the strftime and date_format functions of Smarty, a popular PHP template engine, use the formatting characters of C/UNIX.
6. A messy license
You may think that PHP is free, and so are all the PHP modules mentioned in the manual. 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 them have commercial licenses. So, for every module you use, you have to make sure you agree to his license.
7. Inconsistent function naming rules
Some function names are made up of multiple words. There are generally three kinds of word combinations:
Direct splicing: getnumberoffiles
Separate with an underscore: get_number_of_files
Camel rule: getNumberOfFiles
Most languages choose one of them. But PHP is all used.
For example, if you want to convert some special characters into HTML entities, you will use the function htmlentities (direct concatenation of words). If you want to use the opposite function, you need to use its little brother html_entity_decode. For some special reason, this function name is separated by an underscore. How could that 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 him to make an error. Functions are case-insensitive, so there is no difference between rawurldecode and RawUrlDecode for PHP. This is also bad because both are used and they look different, confusing the reader.
8. The hell cited by magic
Magic references (Magic quote) protect PHP scripts from SQL injection attacks. That's good. But for some reason, you can turn off this configuration in php.ini. So if you want to write a flexible script, you always have to check whether the magic reference is on or off. Such a "feature" should make programming easier when in fact it becomes more complex.
9. Lack of standard framework
A growing website without an overall framework will eventually become a maintenance nightmare. A framework can make a lot of work easier. Now the most popular framework model is the MVC- model, in which the presentation layer, business logic, and database access are separated.
Many PHP sites do not use the MVC- model. They don't even have a framework. Even now there are some PHP frameworks and you can write one yourself. Articles and manuals about PHP do not improve a word of the framework. At the same time, JSP- developers use frameworks like Struts, and ASP developers use. Net, as if these concepts are widely understood by PHP developers. This shows how professional PHP is actually.
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 his weakness. When you keep groping, you will find solutions to some of the problems I have mentioned. So, when the solution is known, why not fix it? And why are these fixes not mentioned in the manual? It's a good thing that an open source language is very popular. But unfortunately, it is not a great language. I hope that one day all the problems will be solved (maybe in PHP6?), and then we will have an open source language that is both open source and easy to use.
By 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.
The above is all the content of this article "what are the serious defects based on PHP?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.