This article is translated from the article Why PHP Was a Ghetto.
One day I was chatting with the boss of a great startup company in DUMBO and talked about why developers in the non-PHP world generally despise PHP and PHP-related communities. He made a point that stuck with me, largely because I had never heard it made like this before.
If you don’t know what complaints most programmers have about PHP, then these complaints would look something like this:
Ugly syntax
Lacks some necessary features that other languages have (before version 5.3, no namespaces, closures)
Inconsistent function naming, usage conventions, and other weird stuff
A mixture of procedural and object-oriented
Basically 80-90% of PHP projects suck like a pile of shit
But the problem with PHP he mentioned is another problem. He doesn't say there's something wrong with the language - he thinks the language is surrounded by a common cultural phenomenon, a cultural tradition usually created by the creators of the language, which now seems to be responsible for some bad programming practices. The method played an encouraging role. That is, it makes PHP code inferior and unmaintainable.
This phenomenon of a language or framework that embodies the founder’s philosophical thoughts and is highly praised by the relevant community does exist. He cited Ruby and its founder Matz as examples. What Matz wanted was a language that was easy to read and write and could improve programmers' work efficiency. Don’t you see how Ruby developers talk about rapid development and the elegance of the language?
Then there is DHH and his Rails framework. And Guido and his Python language. So I was thinking: RasmusWhat about PHP?
Rasmus Lerdorf’s impression is very interesting. He created the original PHP language and has been improving the language. He is worshiped like a god in the PHP community and he enjoys the greatest authority in any aspect of PHP. He was invited to speak at numerous conferences and was hired by a large Internet company (yahoo.com), where he gained everyone's respect - despite the fact that he became the target of most non-PHP programmers. A visual representation of the many problems that despise PHP.
Rasmus advocates avoiding the use of frameworks and treating PHP more as a template language. To him, this approach yields immediate operational efficiency and scalability (the program load is known). For everyone else, this approach resulted in a simmering mess of procedural code and an unmaintainable project. In the approximately 10 years since PHP was born in 1995, all PHP projects have been written according to this guidance.
At the same time, another problem suddenly appeared: before PHP5.0, in the early days of PHP, PHP gained a large number of novice followers. The barrier to entry for this language is surprisingly low. Anyone can download the self-extracting ×AMP Windows program installation package and start using the language within 2 minutes. In addition, there was no real consensus on the MVC pattern in web development methods at that time. So you can imagine what a group of novices can create when they come together with a language that lacks good development practices. An unmaintainable pile of garbage. And the entire environment is like this.
Don't get me wrong - there were still a lot of good PHP developers, even back then. But, like I said, shoddy rookie work is everywhere. When cowboy-style PHP programmers got together to develop programs without guiding principles, the likes of PHPbb, PHPNuke, and many crude .php3 packages emerged. But can you simply blame PHP developers? cannot! Other Web language giants, ASP and Perl, are equally notorious and promote a stew-style development approach.
So this is why PHP gets such a bad rap. It's because of its historical spread. Most PHP developers who had moved to Python, Ruby, and Java did not go back and rethink the language when the MVC concept emerged. In addition, there are some explicit satires like "Ruby boy" Zed Shaw complaining that some programmers' minds are "poisoned by PHP". Comments like this are very popular on RubyInside.
PHP is a concentration camp
But the emergence of frameworks like Zend and CodeIgniter has pushed the language in the right development direction. In fact, it pushed PHP in the opposite direction from what Rasmus wanted to see. Take a look at the Zend and CodeIgniter frameworks, and you will find that they are one of the few programs with well-written documentation and well-written code.
Most developers who learn Ruby also learn Rails and MVC knowledge; PHP has been used for a full 10 years before this. For those who are new to Ruby, it's a shame that Ruby doesn't give them this time to play freely. Rails has ready-made standard guidance, and its entry barrier is relatively high, which usually blocks out some inexperienced developers.
In fact, PHP applications can be written as well as other languages, and they will also have certain advantages in running speed. The rise of the MVC-style development method in the PHP world has only appeared in recent years. We have to admit that we should be grateful to Rails for bringing this change.
So, what does PHP look like today?
Various standards (not unified, but most projects use MVC, few junk procedural programs)
Low entry barrier
Speed and scalability (PHP should be the best among various scripting languages)
Have a good unit testing framework
Have the best documents translated into various languages
In addition, most influential websites on the Internet use PHP as their backend language or tool, such as Facebook, Digg, Wikipedia, WordPress, Drupal, etc. I believe that having an in-depth mastery of PHP will open the door to more unknown areas for a programmer.
If you don’t agree with what’s said above, please leave a comment or email me – I’d like to hear why you don’t think so.
In fact, I am not a PHP fan, I have no feeling for the language. I mostly use PHP because - you guessed it - someone is willing to pay me. So blame it all on this:
If you want to make informed decisions in software design, PHP is your best choice for developing web applications.
By the way, if you are convinced that you want to use PHP to develop your next web application, give CodeIgniter a try. It is a lightweight, plain and super fast PHP framework. I'm a fan of CodeIgniter.

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
