Php decoding js uses the escape transcoding function *** and jsunescape function to decode escape-encoded data * @ param $ str * functionunescape scape ($ str) {$ ret; $ lenstrlen ($ str); for ($ i0; $ I & lt; $ len; $ I ++) {function for decoding js code using escape transcoding in php
/*** Function and js Scape function to decode escape encoded data * @ param $ str */function unescape ($ str) {$ ret = ''; $ len = strlen ($ str); for ($ I = 0; $ I <$ len; $ I ++) {if ($ str [$ I] = '%' & $ str [$ I + 1] = 'u ') {$ val = hexdec (substr ($ str, $ I + 2, 4); if ($ val <0x7f) $ ret. = chr ($ val); else if ($ val <0x800) $ ret. = chr (0xc0 | ($ val> 6 )). chr (0x80 | ($ val & 0x3f); else $ ret. = chr (0xe0 | ($ val> 12 )). chr (0x80 | ($ val> 6) & 0x3f )). chr (0x80 | ($ val & 0x3f); $ I + = 5;} else if ($ str [$ I] = '%') {$ ret. = urldecode (substr ($ str, $ I, 3); $ I + = 2;} else $ ret. = $ str [$ I];} return $ ret ;} /*** function: js escape php implementation * @ param $ string the sting want to be escaped * @ param $ in_encoding * @ param $ out_encoding */function escape ($ string, $ in_encoding = 'utf-8', $ out_encoding = 'ucs-2') {$ return = ''; if (function_exists ('MB _ get_info ')) {for ($ x = 0; $ x <mb_strlen ($ string, $ in_encoding); $ x ++) {$ str = mb_substr ($ string, $ x, 1, $ in_encoding); if (strlen ($ str)> 1) {// multi-byte character $ return. = '% u '. strtoupper (bin2hex (mb_convert_encoding ($ str, $ out_encoding, $ in_encoding);} else {$ return. = '% '. strtoupper (bin2hex ($ str) ;}} return $ return ;}