“刚刚在论坛后台打开“DEBUG 模式运行站点”,结果摘录如下,有什么有用的信息吗?”(引用内容)你贴出来的这些是 PHP 的 Strict Standards(严格标准)提示,不是致命错误,也不是警告(Warning)或错误(Error)。它们说明你的程序里有一些写法在较新版本的 PHP 中已经不被推荐,但当前还能运行。
下面逐类说明这些信息到底在说什么、有没有用、以及你该不该处理。
1. 主要问题:非静态方法被静态调用
提示里最多的一类是:
text
Strict Standards: Non-static method S::escapePath() should not be called statically
Strict Standards: Non-static method S::_escapePath() should not be called statically
Strict Standards: Non-static method S::gp() should not be called statically
Strict Standards: Non-static method S::escapeChar() should not be called statically
Strict Standards: Non-static method S::escapeStr() should not be called statically
Strict Standards: Non-static method S::int() should not be called statically
Strict Standards: Non-static method S::sqlEscape() should not be called statically
Strict Standards: Non-static method Perf::checkMemcache() should not be called statically
Strict Standards: Non-static method pwCache::getData() should not be called statically
意思是:
类 S、Perf、pwCache 里的这些方法,定义时没有加 static 关键字,属于实例方法。
但代码里却用 S::escapePath()、S::gp() 这种静态方式去调用它们。
PHP 在旧版本里允许这么写,但会发 Strict Standards 提示;在 PHP 8 以后,这种调用方式会直接报错。
典型代码可能长这样:
php
class S {
public function escapePath($path) { ... }
}
// 错误/不推荐:
S::escapePath($path);
正确写法应该是:
php
class S {
public static function escapePath($path) { ... }
}
// 或者先实例化:
$s = new S();
$s->escapePath($path);
这说明什么?
你的这套程序(看起来像 PHPWind 论坛,因为出现了 pwCache)比较老,是按旧版 PHP 的宽松规则写的。
现在运行环境的 PHP 版本较高,所以开始提示这些 Strict Standards。
目前还能跑,但如果你升级到 PHP 8+,这些地方会变成致命错误,站点可能直接白屏。
2. 引用赋值问题
text
Strict Standards: Only variables should be assigned by reference in /www/wwwroot/vtu425.com/require/db_connects.php on line 52
意思是:
代码里用了 =& 引用赋值,但右边不是一个变量,而是一个表达式或函数返回值。
例如:
php
$db = &new Database(); // 旧写法,PHP 5 以后不推荐
或者:
php
$result = &getSomething();
这种写法在旧 PHP 里可行,现在会提示 Strict Standards。通常需要改成普通赋值,或者先赋给变量再引用。
3. 这些信息有用吗?
有用,但分情况:
如果你只是临时打开 DEBUG 模式看看,这些提示说明:
程序本身还能运行;
但代码兼容性较差,尤其是对高版本 PHP。
如果你打算长期用高版本 PHP(比如 PHP 7.4、8.x),这些地方迟早要改,否则会从“提示”变成“报错”。
如果你只是用旧版 PHP(比如 5.6),这些提示可以忽略,或者把 error_reporting 里的 E_STRICT 关掉,就不会显示。
4. 建议怎么处理
方案一:不处理,关掉提示
如果你暂时不想改代码,可以在 php.ini 或程序入口处调整错误报告级别,例如:
php
error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_NOTICE);
这样这些 Strict Standards 就不会显示。但注意:这只是“眼不见为净”,并没有真正解决问题。
方案二:修改代码,兼容高版本 PHP
把相关方法改成静态方法,或者改用实例调用。例如:
php
// 原:
S::escapePath($path);
// 改法1:方法加 static
class S {
public static function escapePath($path) { ... }
}
// 改法2:实例化后调用
$s = new S();
$s->escapePath($path);
但你的程序里调用点很多,手动改工作量不小,而且可能涉及第三方程序核心文件,升级后容易被覆盖。
方案三:使用兼容的 PHP 版本
如果这套论坛程序官方只支持到 PHP 5.6 或 7.x,最省事的做法是把运行环境切到它支持的 PHP 版本。这样这些 Strict Standards 自然消失,程

