How Zend Encode works
Anyone who uses PHP knows that it is a scripting tool, and programs written with it must be placed on a web server in the form of source code, so we cannot protect our source code. Everyone knows that the execution efficiency of any script program is relatively low compared to compiled binary code with the same functions. So if there is a tool that can help us write programs in PHP
Just translate it into binary code, which not only improves execution efficiency,
The operation speed has also been accelerated. If there is such a tool, it is
It's a killing two birds with one stone.
Now this is not a dream, Zend Encode is developed for this, it can directly compile scripts into binary code. With Zend Encode, you can compile and distribute the PHP program you wrote to many users without having to disclose your source program code. The compiled binary code can be read transparently by Zend Optimizer, that is, the client can execute the PHP program compiled by Zend Encode as long as he installs Zend Optimizer on his server. The compiler contains part of the code of Zend Optimizer, so the program code is further optimized during the compilation process, which means that the execution efficiency of the script has been improved.
In a sense, Zend Encode is a "PHP compiler". However, it is not a real compiler, because the truly compiled program can run from the original compilation environment, and the programs compiled by Zend Encode need to be supported by Zend Optimizer. Just like compiled Java binary code, it requires the support of JVM. Therefore, Zend Optimizer can be regarded as a virtual machine that compiles good code in PHP. In any case, they need to be used together.
Currently, the operating systems supported by Zend Encode are: Solaris, Linux, FreeBSD and Windows. Zend Encode can be run directly, and PHP is not necessary to be installed in the computer system.
Installation of Zend Encode
Let’s download a software package first! Zend Encode is not a free software, it costs a fee to use it and the price is quite high. Fortunately, a software package is provided for trial, and users can try it for 30 days for free. This package is available directly from above. So, first of all, you need to download the Zend Encode and Zend Optimizer packages on the top. Secondly, download an authorization file license. Since Zend Encode is an authorized product, users need to apply for a license from the previous one.
The application steps are as follows:
To apply for a trial license, you need to provide the ID of the computer you are using, that is, fill in the host ID (actually the MAC address of the network card on your computer). The method to view the computer ID is as follows: download a program, decompress it and get the program lmutil, run it, and it will generate a sequence string based on the hardware characteristics of the system. Fill in this serial number into the host ID of the application license page, and a license will be generated for the user within 48 hours. Download this license file with the file name, which can only be used on this computer.
1. Also unzip the Zend Encode package to /usr/local/Zend directory. After decompression is completed, there is an additional zendenc file in the directory, which is the "compiler".
2. Copy the license file to /usr/local/Zend directory and install it.
Installation of Zend Optimizer
After completing the installation of Zend Encode, half of the task was completed. To use the compiled PHP binary code, an interpreter - Zend Optimizer must be installed. With its support, the compiled PHP binary files can be executed correctly.
Unlike Zend Encode, Zend Optimizer is a free software whose main function is to speed up the running of PHP script files. It is said that with the optimization of Zend Optimizer, the execution efficiency of the program can be improved by 600%. After the author's simple test, the execution efficiency has indeed been greatly improved.
The steps to install Zend Optimizer are as follows:
1. Unzip the Zend Optimizer package and copy the file to the /usr/local/Zend/lib directory.
2. Open the /usr/local/lib/ file and add the following two lines to the file:
zend_optimizer.optimization_level=15
zend_extension=”/usr/local/Zend/lib/ ”
3. Restart the Apache server to make the above update take effect.
Use of Zend Encode
Now that the preparations are all done, we will write a simple PHP script, compile it using Zend Encode to see how it works. Let's first write the simplest script to see if the compiled code can be executed:
#vi
<? Phpinfo(); ?>
Compile it:
#[root@mail Zend]# ./zendenc
Zend Encoder Unlimited (TEST DRIVE) v1.1.0 (c) Zend Technologies, 1999-2000
Licensed to: xqkred.
Compiling …
Done encoding .
Optimizing… Done.
Saving… Done.
OK, successfully compiled. However, the compiled program size is much larger than before.
Copy it to the publishing directory of the web server and type localhost/ in the browser, wow! The compiled code can run successfully! Since we are using the trial version of Zend Encode, a picture will appear at the top of the page, indicating that this is a binary file generated by the Zend Encode trial package. In the official version of the software, the pictures will not reappear.
Let’s take a look at its execution efficiency! First, write a small calculation program to roughly estimate:
[]
<?
r=time();
for( 121=0;121<1000000;121++) {
if((121%20)!=0) {echo 121; echo “,”;}
else { echo “<br>”;}
}
=time();
echo “<br>”; echo “It used:”; echo -r; echo ” seconds”;
?>
When this program is executed, it takes the system time, and then the system time is obtained after completion. The difference between the two values is the time required for the entire program to run. It is executed first without compilation, and then compiled with Zend Encode and then executed again. Comparative results: Without compilation, the average time required to run is 19 seconds, and the average execution time of compiled code is 9 seconds. It seems that the execution efficiency has been greatly improved.
Anyone who uses PHP knows that it is a scripting tool, and programs written with it must be placed on a web server in the form of source code, so we cannot protect our source code. Everyone knows that the execution efficiency of any script program is relatively low compared to compiled binary code with the same functions. So if there is a tool that can help us write programs in PHP
Just translate it into binary code, which not only improves execution efficiency,
The operation speed has also been accelerated. If there is such a tool, it is
It's a killing two birds with one stone.
Now this is not a dream, Zend Encode is developed for this, it can directly compile scripts into binary code. With Zend Encode, you can compile and distribute the PHP program you wrote to many users without having to disclose your source program code. The compiled binary code can be read transparently by Zend Optimizer, that is, the client can execute the PHP program compiled by Zend Encode as long as he installs Zend Optimizer on his server. The compiler contains part of the code of Zend Optimizer, so the program code is further optimized during the compilation process, which means that the execution efficiency of the script has been improved.
In a sense, Zend Encode is a "PHP compiler". However, it is not a real compiler, because the truly compiled program can run from the original compilation environment, and the programs compiled by Zend Encode need to be supported by Zend Optimizer. Just like compiled Java binary code, it requires the support of JVM. Therefore, Zend Optimizer can be regarded as a virtual machine that compiles good code in PHP. In any case, they need to be used together.
Currently, the operating systems supported by Zend Encode are: Solaris, Linux, FreeBSD and Windows. Zend Encode can be run directly, and PHP is not necessary to be installed in the computer system.
Installation of Zend Encode
Let’s download a software package first! Zend Encode is not a free software, it costs a fee to use it and the price is quite high. Fortunately, a software package is provided for trial, and users can try it for 30 days for free. This package is available directly from above. So, first of all, you need to download the Zend Encode and Zend Optimizer packages on the top. Secondly, download an authorization file license. Since Zend Encode is an authorized product, users need to apply for a license from the previous one.
The application steps are as follows:
To apply for a trial license, you need to provide the ID of the computer you are using, that is, fill in the host ID (actually the MAC address of the network card on your computer). The method to view the computer ID is as follows: download a program, decompress it and get the program lmutil, run it, and it will generate a sequence string based on the hardware characteristics of the system. Fill in this serial number into the host ID of the application license page, and a license will be generated for the user within 48 hours. Download this license file with the file name, which can only be used on this computer.
1. Also unzip the Zend Encode package to /usr/local/Zend directory. After decompression is completed, there is an additional zendenc file in the directory, which is the "compiler".
2. Copy the license file to /usr/local/Zend directory and install it.
Installation of Zend Optimizer
After completing the installation of Zend Encode, half of the task was completed. To use the compiled PHP binary code, an interpreter - Zend Optimizer must be installed. With its support, the compiled PHP binary files can be executed correctly.
Unlike Zend Encode, Zend Optimizer is a free software whose main function is to speed up the running of PHP script files. It is said that with the optimization of Zend Optimizer, the execution efficiency of the program can be improved by 600%. After the author's simple test, the execution efficiency has indeed been greatly improved.
The steps to install Zend Optimizer are as follows:
1. Unzip the Zend Optimizer package and copy the file to the /usr/local/Zend/lib directory.
2. Open the /usr/local/lib/ file and add the following two lines to the file:
zend_optimizer.optimization_level=15
zend_extension=”/usr/local/Zend/lib/ ”
3. Restart the Apache server to make the above update take effect.
Use of Zend Encode
Now that the preparations are all done, we will write a simple PHP script, compile it using Zend Encode to see how it works. Let's first write the simplest script to see if the compiled code can be executed:
#vi
<? Phpinfo(); ?>
Compile it:
#[root@mail Zend]# ./zendenc
Zend Encoder Unlimited (TEST DRIVE) v1.1.0 (c) Zend Technologies, 1999-2000
Licensed to: xqkred.
Compiling …
Done encoding .
Optimizing… Done.
Saving… Done.
OK, successfully compiled. However, the compiled program size is much larger than before.
Copy it to the publishing directory of the web server and type localhost/ in the browser, wow! The compiled code can run successfully! Since we are using the trial version of Zend Encode, a picture will appear at the top of the page, indicating that this is a binary file generated by the Zend Encode trial package. In the official version of the software, the pictures will not reappear.
Let’s take a look at its execution efficiency! First, write a small calculation program to roughly estimate:
[]
Copy the codeThe code is as follows:
<?
r=time();
for( 121=0;121<1000000;121++) {
if((121%20)!=0) {echo 121; echo “,”;}
else { echo “<br>”;}
}
=time();
echo “<br>”; echo “It used:”; echo -r; echo ” seconds”;
?>
When this program is executed, it takes the system time, and then the system time is obtained after completion. The difference between the two values is the time required for the entire program to run. It is executed first without compilation, and then compiled with Zend Encode and then executed again. Comparative results: Without compilation, the average time required to run is 19 seconds, and the average execution time of compiled code is 9 seconds. It seems that the execution efficiency has been greatly improved.