Overview: The day before yesterday, a piece of code that can improve operating efficiency by 70% suddenly appeared in the PHP section of github, triggering complaints and ridicules from many netizens around the world, "awesome!", "well done!", "PHP is the world The first language! "The programmers who are usually serious and hardworking give full play to their humorous side, and GitHub has become a sea of joy.A few days ago, a piece of code that can improve operating efficiency by 70% suddenly appeared in the PHP section of github, which triggered complaints and ridicules from many netizens around the world, "awesome!", "well done!", "PHP is the world's No. 1 One language!" Programmers who usually keep their noses in words and work hard have given full play to their humorous side, and GitHub has become a sea of joy.
Let’s take a look at this piece of divine code first:
What this code does is one thing: disable PHP’s garbage collector. Then netizens tested the effect of using the garbage collector with PHP disabled:
Before: Memory usage: 163.66MB (peak: 403.82MB), time: 246.25s
After: Memory usage: 163.34MB (peak: 350.36MB), time: 99.55s
The time required to run a certain PHP program was reduced from 246.25 seconds to 99.55 seconds!Before: Memory usage: 152.71MB (peak: 335.9MB), time: 195.99s
After: Memory usage: 164MB (peak: 308.02MB), time: 104.06s
The time it takes for a PHP program to run from 195.99 seconds reduced to 104.06 seconds!...In general, disabling the garbage collector can improve PHP's operating efficiency by 70%.
Since PHP’s garbage collection is so unreliable, what was the original intention of its previous design?
Because in C/C++, memory management is a very troublesome thing. The use and release of memory require programmers to write programs to operate manually. If something is omitted, it may cause a waste of resources or even a memory leak. Therefore, in order to avoid this problem during PHP design, a garbage collector was introduced to automatically release the memory of useless objects.
It is worth mentioning that PHP will consume extra time when running the recycling algorithm. Although in smaller projects, this additional consumption is minimal, when running large projects, since multiple recycling threads are started at the same time, this consumption will have a great impact. The most intuitive manifestation is the program running The time got longer.
Disabling PHP’s garbage collection is the simplest and crudest way to improve the efficiency of the program. This is just like if a leg or foot is injured, the easiest way is to amputate it.
As soon as the god-level code was announced, the programmers on github were overjoyed:
Homm, who arrived first, expressed his surprise at this processing method and did not understand why it was done, and objectively evaluated this processing The method didn't look good:
Then smilingtechguy came and started teasing: "Well, there is no comment, let's disable the PHP kernel, and we won't explain why we do this."
Then it started to get out of hand:
Some were making fun of you:
Some were complaining and teasing:
Just talking about PHP It is the world's number one language and has versions in several countries. It is said that just using a few pieces of code can increase efficiency by 70%. PHP is definitely the number one language in the world:
There are also cute ones:
PHP’s garbage collection mechanism has become everyone’s joke. We also know that simply disabling PHP garbage collection cannot solve problems such as memory overflow. How PHP handles the contradiction between memory management and operating efficiency in the future will be a question. A long and arduous matter.
The above has introduced the joy of Github, and the PHP god-level code has caused a lot of complaints, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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 CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool