PHP (Hypertext Preprocessor), hypertext preprocessor, is a universal open source scripting language. Its syntax draws on the advantages of C language, Java and Perl. It is free, fast and efficient, and is mainly suitable for the field of Web development.
Currently, more than 60% of the world’s 50 million Internet websites use PHP technology. 394 of the Alexa TOP500 Chinese websites use PHP. More than 80% of domestic dynamic websites use PHP for development. In the Web back-end language PHP’s global language market share reaches 80%.
Like Facebook, Google, Sina, Baidu, YouTube, and Tencent, they all use PHP.
Eight advantages of the PHP language:
1. Open source code, all PHP source code is actually available.
2. Freeness. Compared with other technologies, PHP itself is free and open source code.
3. Fastness, program development is fast, operation is fast, and the technology itself is learned quickly. Embedded in HTML: Because PHP can be embedded in the HTML language, it is comparable to other languages. Editing is simple, practical, and more suitable for beginners.
4. Strong cross-platform capability. Since PHP is a script that runs on the server side, it can run under UNIX, LINUX, WINDOWS, and Mac OS.
5. Professional and focused, PHP mainly supports scripting languages, both of which are C-like languages.
6. High efficiency. PHP consumes relatively few system resources.
7. Object-oriented. In php4 and php5, object-oriented aspects have been greatly improved. PHP can be used to develop large-scale commercial programs.
8. Image processing, use PHP to dynamically create images. PHP image processing uses GD2 by default. And can also be configured to use image magick for image processing.
There are three common operating modes of PHP: CGI, FastCGI, and APACHE2HANDLER.
1. CGI
CGI is the common gateway interface. It is a program. In layman’s terms, CGI is like a bridge that connects the web page and the WEB server. The execution program is connected, it passes the instructions received by the HTML to the server's execution program, and then returns the results of the server's execution program to the HTML page. CGI is extremely cross-platform and can be implemented on almost any operating system.
2. FastCGI
fast-cgi is an upgraded version of cgi. FastCGI is like a long-live CGI. It can be executed all the time, as long as it is activated. , it won’t take time to fork every time. PHP uses PHP-FPM (FastCGI Process Manager), the full name of PHP FastCGI Process Manager, for management.
But every Web request to PHP must re-parse php.ini, reload all extensions and re-initialize all data structures. With FastCGI, all of this happens only once, when the process starts. An added bonus is that persistent database connections work.
3. APACHE2HANDLER
PHP is an Apache module. After the system is started, the Apache server pre-generates multiple process copies to reside in the memory. Once a request occurs, these will be used immediately. The idle child process is processed, so that there is no delay caused by spawning the child process. These server copies do not exit immediately after processing an HTTP request, but stay in the computer waiting for the next request. The response to client browser requests is faster and the performance is higher.
How to protect your own PHP code:
1. Code obfuscation + encryption
It is to base64 encrypt the code, and then string the string in base64 Mapping (randomly generated dictionary obfuscation) and then eval execution can be 100% cracked and restored.
2. Confuse garbled characters
Code obfuscation variables and some other things are similar to the principle of 1, but the string is changed to ascii 127 to 255. Non-humans and editors Incomprehensible characters can be 100% cracked and restored, it's just a matter of time.
3. Distribute opcode
Instead of distributing the code, precompile the PHP code first and distribute the opcode. After PHP7, opcache will deeply integrate this thing. After PHP7, you can use this method to protect the source code. But it will also be decompiled by opcode and will be cracked.
4. Confusion + encryption + writing PHP extensions
Confusion + encryption + writing PHP extensions, but as long as they are open source PHP extensions will be cracked, unless you write the encryption algorithm yourself and convert PHP Encrypt the code, and then use the C voice to write extended closed source. Others do not know your encryption ideas and cracking ideas, and the possibility of being cracked is very small.