| 錯誤信息 | PHP 版本 | 原因 |
|---|---|---|
| Deprecated: preg_replace(): The /e modifier is deprecated | 5.5+ | /e 修飾符已棄用,7.0+ 移除 |
| Strict Standards: Only variables should be passed by reference | 5.3+ | array_shift 等函數需變量引用 |
| Strict Standards: Non-static method ... should not be called statically | 5.4+ | 靜態調用非靜態方法 |
| Redefining already defined constructor | 7.0+ | PHP 4 風格構造函數與 __construct 衝突 |
文件:includes/cls_template.php 第 300 行左右
// 原代碼
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
// 修復為
return preg_replace_callback(
"/{([^\}\{\n]*)}/",
function ($matches) {
return $this->select($matches[1]);
},
$source
);
文件:includes/cls_template.php 第 422 行左右
// 原代碼
$tag_sel = array_shift(explode(' ', $tag));
// 修復為
$tag_arr = explode(' ', $tag);
$tag_sel = array_shift($tag_arr);
文件:includes/lib_base.php 第 346 行
// 原代碼 return cls_image::gd_version(); // 修復為 $image = new cls_image(); return $image->gd_version();
文件:includes/modules/integrates/ 下各文件
// 將 __construct 移到類開頭,舊構造函數重命名或刪除
class cls_sql_dump {
function __construct(&$db, $max_size = 0) {
$this->db = $db;
$this->max_size = $max_size;
}
// 靜態方法聲明
static function get_random_name() { ... }
}
// 1. 隱式兼容性:strpos/strstr 等 needle 為非字符串
// 修復:strpos($haystack, (string)$needle)
// 2. htmlentities 默認編碼變更
htmlentities($str, ENT_QUOTES, 'UTF-8'); // 顯式指定編碼
// 3. 動態屬性棄用 (8.2+)
// 類中聲明屬性或使用 #[AllowDynamicProperties]
// 4. 彌補缺失函數
if (!function_exists('get_magic_quotes_gpc')) {
function get_magic_quotes_gpc() { return false; }
}