


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 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 limit on the number of recursive functions it can tolerate is significantly smaller 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. No namespace
Imagine a certain I personally 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: Smarty (a popular PHP template engine)'s strftime function and date_format function 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
Separated by underscores: get_number_of_files
Camel’s rule: getNumberOfFiles
Most languages choose one of them One middle school. 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 can this be? You know there is a function called strpad. Or is it 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.
8. The hell of magic quotes
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 turn into 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, when the solution is known, why can't it be fixed? Also, why aren't these fixes mentioned in the manual? It's a good thing that an open source language is very popular. But unfortunately, it's not a great language. I hope that all the problems will be solved one day (maybe in PHP6), and 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.

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor
