Home >Backend Development >PHP Tutorial >JS 代码转 PHP 多谢

JS 代码转 PHP 多谢

WBOY
WBOYOriginal
2016-06-13 10:24:391043browse

JS 代码转 PHP 谢谢
这是是JS的, 我想转成PHP的,

不懂PHP,谢谢呀

function Getkey(key, sc) {
return (key * 0x0063 + sc) % 0x100
}
function Apple(str) {
var len = str.length / 2;
var i = 1;
var tmp = '';
var key = eval("0x" + str.charAt(0) + str.charAt(1));
while (i istr = eval("0x" + str.charAt(i * 2) + str.charAt(i * 2 + 1));
istr = key ^ istr;
if (istr == 2) {
i = i + 1;
key = Getkey(key, istr);
istr = eval("0x" + str.charAt(i * 2) + str.charAt(i * 2 + 1));
istr = key ^ istr;
jstr = istr;
i = i + 1;
key = Getkey(key, istr);
istr = eval("0x" + str.charAt(i * 2) + str.charAt(i * 2 + 1));
istr = key ^ istr;
jstr = jstr * 256 + istr;
tmp = tmp + String.fromCharCode(jstr)
} else tmp = tmp + String.fromCharCode(istr);
i = i + 1;
key = Getkey(key, istr)
}
return tmp
}


------解决方案--------------------

PHP code
echo    Apple("123123");//输出 "#:" 对吗?function Getkey($key, $sc){    return    ($key * 0x0063 + $sc) % 0x100;}function Apple($str) {    $len    = mb_strlen($str, "GBK") / 2;    $i    = 1;    $tmp    = '';    $key    = "0x" . $str{0} . $str{1} + 0;    while ($i <font color="#e78608">------解决方案--------------------</font><br>楼上厉害!<br><font color="#e78608">------解决方案--------------------</font><br>
探讨

请教一下,为啥变量,前面都要加个 “$“???
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn