我從PHP 5我的服務器上剛剛更新了PHP到PHP 7和我得到這些警告:警告:preg_replace_callback():需要參數2
警告:preg_replace_callback()[function.preg替換-callback0]:需要參數2'chr(\ 1)'爲有效回調
警告:preg_replace_callback()[function.preg-replace-callback0]:需要參數2,'chr(0x \ 1 )',成爲一個有效的回調
警告:preg_replace_callback()[function.preg-replace-callback0]:需要參數2,'chr(\ 1)',作爲一個VA蓋回調
警告:preg_replace_callback()[function.preg替換-callback0]:要求參數2, 'CHR(0X \ 1)',是一個有效的回調
這是PHP代碼:
private function _decode($source)
{
$source = html_entity_decode($source, ENT_QUOTES, 'UTF-8');
$source = preg_replace_callback('/&#(\d+);/me',"chr(\\1)", $source);
$source = preg_replace_callback('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);
return $source;
}
的警告又是從何而來:
$source = preg_replace_callback('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);
我怎麼能解決這個問題?
工作!但現在我從$ source = preg_replace_callback('/&#(\ d +);/me',「chr(\\ 1)」,$ source);我如何解決這個問題?謝謝 –
@MateiZoc完全一樣。查看使用的代碼並嘗試將功能複製到其他方法。你實際上只需要複製該行,替換正則表達式並替換'chr'返回的內容。你甚至不需要使用十六進制,因爲它是十進制數。 – h2ooooooo
@ h2ooooooo我試試$ source = preg_replace_callback( '/&#(\ d +);/me', function($ m){return chr(hexdec($ m [1]));},// Now a Closure $ source );但我得到錯誤警告:preg_replace_callback()[function.preg-replace-callback0]:不再支持/ e修飾符,請使用preg_replace_callback而不是 警告:preg_replace_callback()[function.preg-replace-callback0]:/e修飾符不再支持,請使用preg_replace_callback代替 –