JavaScriptを手作業でPHPに変換しようとしています。私が変換しようとしているスクリプトは次のとおりです。str_replaceの関数を使用する
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 = "";
私は何が出ていることである。
if ($s) {
$r = $r . "\"" . $s;
} else {
$r = $r . "\"";
}
$r = $r . "\\\\\"+" . str_replace([0-7],function($c, $GlobalVar, $b){
return $GlobalVar.".".$b[$c]."+";
},ord($n));
しかし、私は取得しています:
The localhost page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
私が使用して想定していますstr_replace
の関数がスクリプトを壊していますが、削除するとJavascriptコードと同じ機能が見つかるかどうかわかりません。どんな助けもありがとうございます。
PHPのログ:あなたが関数に渡している変数が文字列でない
Object of class Closure could not be converted to string
:
[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
あなたはおそらく(preg_replace_callback 'を探してください) 'これで、検索として正規表現を使用し、置換としてコールバック関数を使用することができます。 – Rizier123
エラーログはどこにありますか? (Ubuntuを実行中)@PaulCrovella –
エラーログの場所については、http://stackoverflow.com/questions/5127838/where-does-php-store-the-error-log-php5-apache-fastcgi-cpanelを参照してください。 – chris85