Nine reasons to use PHP as a super-large website

Source: Internet
Author: User
Tags php template
Nine reasons to use PHP as a large web site


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 larger sites than small amateur sites.

1. Bad support for recursion
recursion is a mechanism by which a function calls itself. This is a powerful feature that makes some complex things very simple. One example of using recursion is a quick sort (quicksort). Unfortunately, PHP is not good at recursion. Zeev, a PHP developer, said: "Php?4.0 (Zend) uses stacks for dense data instead of using heaps. This means that the number of recursive functions it can tolerate is significantly less than that of other languages. "See bug?1901. This is a very bad excuse. Each programming language should provide good recursive support.
2, many PHP modules are not thread-safe
a few years ago, Apache published a Web serviceversion 2.0 of the device. This version supports multithreaded mode, in which a part of the software can run multiple simultaneously. PHP's inventor says the core of PHP is thread-safe, but non-core modules are not necessarily. But 10 times there are nine times you want to use this module in a PHP script, but this makes your script unsuitable for Apache multithreaded mode. This is also why the PHP team does not recommend running PHP in the multithreaded mode of apache?2. Poor multithreaded mode support makes PHP often considered one of the reasons why Apache?2 is still not popular.
3, PHP? Not sound for business reasons
by using caching, PHP's performance can be spiked 500%[see benchmark]. So why is the cache not built in PHP? Because of Zend--php's maker, it sells its own zend? Accelerator, so of course, they do not want to abandon their commercial products this piece of fat.
But there is another alternative:? Apc.? (Zend later launched Zend?) Optimizer, free accelerator-translator)
4. No namespace
Imagine someone making a PHP module to read a file. 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 these two modules at the same time, because PHP doesn't know which function you're going to use. But there is a very simple solution, that is the namespace. It was suggested that PHP5 be added to this feature, but unfortunately he did not. Now, without namespaces, each function must be prefixed with a module name to avoid name collisions. This causes the function name to be long, for example Xsl_xsltprocessor_transform_to_xml makes the code difficult to write and understand.
5, non-standard date format characters
Many programmers are familiar with the date format characters, which are from UNIX and C languages. Some other programming languages use this standard, but strangely enough, PHP has its own set of completely incompatible date format characters. In C, "%j" means the day of the year, in PHP he represents the day of the one month. But what makes things more confusing is: Smarty? (A very popular PHP template engine), the Strftime function and the? Date_format function, but use the formatted character of the C/unix.
6. Confusing license
you may think PHP is free, and all of the PHP modules mentioned in the manual are free. Wrong! For example, if you want to generate a PDF file in PHP, you will find two modules in the manual: PDF? ClibPDF. But both of these are commercially licensed. So, every module you use, you have to make sure that you agree to his license.
7. Inconsistent function naming rules
Some function names are made up of multiple words. Generally there are three kinds of word combinations of habits:
Direct splicing: Getnumberoffiles
separated by underscores: Get_number_of_files
Camel rule: getnumberoffiles
Most languages choose one of them. But PHP is used.
8. Magic Quotes of Hell
Magic References (magic?quote) protect PHP scripts from SQL injection attacks. This is good. But for some reason, you can turn this configuration off 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 an "attribute" should make programming easier and in fact become more complex.
9. Lack of standard framework
A growing web site does not have an overall framework and 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, where 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 frame. Even now there are some PHP frameworks at the same time you can write your own, about PHP articles and manuals do not improve the framework of a word. At the same time jsp-developers use. NET as a framework for struts and ASP developers, it seems as if these concepts are widely understood by PHP developers. This explains how much PHP is actually more professional.
Summary
for very small projects, it can be a very satisfying programming language. But for larger and more complex projects, PHP is showing his weaknesses. As you continue to grope, you will find solutions to some of the problems I mentioned. So, when the solution is known, why can't we fix him? Also, why are these patches not mentioned in the manual?? The popularity of an open source language is a good thing. More detailsA collection of programming language tutorials can be logged in E mentor Web.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.