PHP Code Protection--zend Guard the use of detailed _php example

Source: Internet
Author: User
Tags current time php source code zend
The role of Zend Guard is to protect the PHP source code from being decompile, unauthorized customization, unauthorized use, and redistribution, using a compilation process. Moreover, it is the owner of PHP Zend Company developed, is fully tailored to the PHP protection of God.
Below, please join me to learn to use Zend Guard, encryption to protect our PHP source code bar.
actual combat: Encrypt PHP source code
Next let's prepare a simple PHP program test.php to test whether it can be protected by Zend Guard. The code for test.php is as follows:
Copy Code code as follows:

Phpinfo ();

Open Zend Guard, click from the File menu, and create a new item, as shown in Figure 1. Click Next to enter the directory and file to add the interface, because we are only testing a file, so point add File adds test.php, then click Finish to build the project.
At this point, Zend guard automatically opens the newly created project, lists the files in the project on the left side of the interface, and lists the relevant information for the project on the right. Now we can compile the source code. Click Encode (compiled) in the links on the right, and the console window at the bottom of the interface displays "the operation has completed successfully.", meaning that the compilation is complete.
Now go to the encrypted file to save the directory, you will see that there is a test.php, it is the same as the original test.php? Using the editing software to open it, you can see that it is no longer the original content, as shown in Figure 2. Note: You must save the original code, otherwise lost, even you have no way to view and modify.
Next Test the encrypted code, access the encrypted PHP program from the browser, oops, error, can't run, and display the information as shown in Figure 3. Originally, the use of Zend Guard encrypted PHP program, but also need a partner-zend Optimizer, to normal implementation and improve efficiency. Installation can be downloaded from the During installation, the "Choose the PHP.ini folder" step indicates the location of the configuration file php.ini on the system, "Choose the Web server ' root folder" This step indicates the location where the Web server software is set up. After the installation is complete, open php.ini with Notepad, and at the end we will see configuration information similar to the following:
zend_extension_manager.optimizer_ts= "E:\Program files\zend\zendoptimizer-3.3.0\lib\optimizer-3.3.0"
zend_extension_ts= "E:\Program Files\zend\zendoptimizer-3.3.0\lib\zendextensionmanager.dll"
This means that Zend Optimizer has been installed successfully, we can restart the Web server software, let Zend Optimizer effective. Note: If the server you are using has already been installed or contains Zend Optimizer, you do not have to install it again.
Now again from the browser to access the encrypted PHP program to try, sure enough to run normally, from the display of information, we can see Zend Optimizer information
Analytic Zend Guard Encryption principle
Let us look at the process, we can Zend Guard protection principle at a glance. The PHP source code is compiled into encrypted code by Zend Guard, and then executed by loading the PHP Zend Optimizer. The program that is distributed to others is the encrypted code that can be executed, but without the source code, others will not be able to view and modify it. Therefore, we can add the appropriate code in the program, to detect the current time of the system, to see whether the pre-set period is exceeded, if more than, quit the program does not allow to continue execution.

Zend Guard's work is similar to Java, compiled PHP programs like a compiled Java binary code, requires the support of the JVM to run, Zend Optimizer can be seen as a PHP virtual machine. Zend Guard and Zend optimizer work together to complete the compilation of encryption and the execution of compiled code.

The license management aspect is a deeper use that can be used to generate license files that restrict the use of programs by selecting different licensing modes, such as the number of users that are used concurrently, time limits, network segments, or specific servers. Interested readers can look at the Help files Zend guard themselves to understand the specific usage.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.