: This article mainly introduces the variable length bytecode algorithm. if you are interested in the PHP Tutorial, you can refer to it. I recently read the book large-scale WEB service development technology. The book mentions the "variable length bytecode algorithm" to compress data and reduce disk I/O.
Variable length bytecode algorithm:
The maximum bit (subscript 7) of any byte is used only as the flag, and is multiplied by the corresponding power of 128 according to the location of the byte;
This is his pseudocode.
After careful research, I translated it into a PHP version:
Int (133) [1] => string (1) "1" [2] => int (130) [3] => string (1) "2" [4] => int (160)} array (3) {[0] => int (5) [1] => int (130) [2] => int (288)} // write binary $ h = fopen('ejz3.txt ', 'wb'); foreach ($ a as $ k => $ v) {$ str3 = pack ('H * ', sprintf ("% 02x", $ v); fwrite ($ H, $ str3);} fclose ($ h ); // read binary $ str2 = file_get_contents('ejz3.txt '); $ str2 = unpack ("H *", $ str2); $ value = str_split ($ str2 [1], 2 ); foreach ($ value as $ k =>$ v) {$ value [$ k] = base_convert ($ v, 16, 10 );}
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces the variable-length bytecode algorithm, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.