前にPHPを7にバージョンアップしたときにSmartyでエラーになった。
エラー内容
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
in /var/www/php/library/pear/Smarty/Smarty_Compiler.class.php on line 270
preg_replace()はPHP7から廃止になったので、代わりにpreg_replace_callback()を使うように修正する。
元ソース
$source_content = preg_replace($search.'e', "'"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "'"
, $source_content);
↓修正後
$source_content = preg_replace_callback($search
, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count(\$matches[0], \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);