PHPを7にバージョンアップたら、Smarty_Compiler.class.phpでWarningが出現。
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/……/Smarty/Smarty_Compiler.class.php on line 271
エラーの箇所を見てみると……↓
PHP
1$source_content = preg_replace($search.'e', "'" 2 . $this->_quote_replace($this->left_delimiter) . 'php' 3 . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'" 4 . $this->_quote_replace($this->right_delimiter) 5 . "'" 6 , $source_content);
preg_replace()が使えなくなったようで、preg_replace_callback()に書き換えをしました。
PHP
1$source_content = preg_replace_callback($search 2 , function($matches) { 3 return "'" 4 . $this->_quote_replace($this->left_delimiter) . 'php' 5 . "' . str_repeat(\"\n\", substr_count('" . $matches[0] . "', \"\n\")) .'" 6 . $this->_quote_replace($this->right_delimiter) 7 . "'"; 8 } 9 , $source_content);
すると、今度はSmarty errorが出現してしまいました……。
Fatal error: Smarty error: [in エラーか所のパス]: syntax error: unrecognized tag: php' . str_repeat(" ", substr_count('{*バージョン情報 {$zend_version (Smarty_Compiler.class.php, line 458) in /var/www/……/Smarty/Smarty.class.php on line 1095
エラーが出た箇所では、バージョン情報をコメントアウトしているだけです。
PHPをバージョンアップする前はちゃんと動いていたので、preg_replace_callback()の書き換えミスをしているんじゃないかと思うのですが、どこを間違っているのか分かりません……。
ついでに、Smarty_Compiler.class.phpの上記箇所で何をしているのかもよく分かりません。。
PHPとかSmartyとかに詳しい方、教えていただきたいです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。