Use APC to encrypt php code

Source: Internet
Author: User
Tags apc
The principle is actually very simple. It is to use apc_bin_dumpfile to generate opcode files for many PHP file codes. When used, load the opcode file apc_bin_loadfile. The original code file is cleared. Generate a single opcode file. Note that the apc. ini file is set to apc. stat = off; var_dump (ini_get (apc. stat); $ arr_fi

The principle is actually very simple, that is, many PHP file codes are generated into opcode files using apc_bin_dumpfile; when used, apc_bin_loadfile is loaded into the opcode file. The original code file is cleared. Generate a single opcode file. Note that the apc. ini file is set to apc. stat = off; var_dump (ini_get ('apc. stat'); $ arr_fi

The principle is actually very simple, that is, many PHP file codes are generated into opcode files using apc_bin_dumpfile; when used, apc_bin_loadfile is loaded into the opcode file. The original code file is cleared.


Generate a single opcode file. Note that apc. ini is set to apc. stat = off;


Var_dump (ini_get ('apc. stat'); $ arr_files = glob_recursive ("/var/www/html/models/*. php"); // echo'
';print_r($arr_files );var_dump(__DIR__.'/models.bin');foreach ($arr_files as $filename) {    //echo "$filename size " . filesize($filename) . "\n
"; @require_once $filename; //$output = str_replace('/models/', '/models2/', $filename); //echo $output;exit; //@mkdir(dirname($output),true); //file_put_contents($output, '');}foreach($arr_files as $filename){//recompile again,maybe not usableapc_compile_file($filename);}$flag = @apc_bin_dumpfile($arr_files, array(), __DIR__.'/models.bin');var_dump($flag);




And then you can use it.

$flag = apc_bin_loadfile( BAOGG_ROOT.'models.bin');set_include_path(get_include_path() . PATH_SEPARATOR . ‘/var/www/html/models/’);




Refer:

Http://www.laruence.com/2012/08/16/2701.html

Http://hi.baidu.com/leolance/item/d115f9f6475208ca531c2693

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: info-contact@alibabacloud.com 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.