I'm trying to convert some Javascript to PHP manually. The script I'm trying to convert is:
if (s)
r += "\"" + s;
else
r += "\"";
r += "\\\\\"+" + gv + "._+" + n.toString(16).replace(/[0-9a-f]/gi, function(c) {
return gv + "." + b[parseInt(c, 16)] + "+"});
s = "";
What I have come up with is:
if ($s) {
$r = $r . "\"" . $s;
} else {
$r = $r . "\"";
}
$r = $r . "\\\\\"+" . str_replace([0-7],function($c, $GlobalVar, $b){
return $GlobalVar.".".$b[$c]."+";
},ord($n));
But I'm getting:
The localhost page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
I'm assuming using a function in str_replace
is breaking the script, but if I remove it I don't know if I can find the same functionality as the Javascript code. Any help is appreciated.
Php Log:
[Thu Aug 25 12:46:43.157926 2016] [:error] [pid 5864] [client 127.0.0.1:53936] PHP Catchable fatal error: Object of class Closure could not be converted to string in /var/www/html/html/test.php