$options = Typecho_Widget::widget('Widget_Options');
$sUrl = str_ireplace('/', '\/', rtrim($options->siteUrl, '/'));
$preg = '#(<a .*?href=")(?!' . $sUrl . ')([^"]+)"(.*?<\/a>)#ise';
$text = preg_replace($preg, "stripslashes('$1') . '$options->siteUrl' . 'go.html?url=' . base64_encode('$2') . '\" target=\"_blank\ "' . stripslashes('$3')", $text);
After the code was put into PHP7.0, an error was reported. According to the prompts, I learned that preg_replace was abandoned and had to be replaced by preg_replace_callback. How to do it?
擁有18年軟件開發(fā)和IT教學經(jīng)驗。曾任多家上市公司技術總監(jiān)、架構(gòu)師、項目經(jīng)理、高級軟件工程師等職務。 網(wǎng)絡人氣名人講師,...
It’s not that preg_replace is abandoned, it’s the /e modifier that is abandoned.
I think it should probably be changed like this
preg_replace_callback($preg,
function ($matches) {
return stripslashes($matches[1]).$options->siteUrl.'go.html?url='.base64_encode($matches[2]).'\" target=\"_blank\"'.stripslashes($matches[3]);
});
Where can I see that this function has been abandoned?
http://php.net/manual/zh/func...
Support (PHP 4, PHP 5, PHP 7)
Post an error message
Preg-prefixed functions are not obsolete, but eregi-prefixed functions are obsolete