我目前正在处理其他人为WordPress撰写的破碎主题.全新安装后会抛出500错误.检查我的本地机器上的代码后,我能够提示以下内容:
public static function skip_script($conf) {
$hook_suffix = isset($GLOBALS['hook_suffix']) ? $GLOBALS['hook_suffix'] : null;
if (isset($conf['variable'])) {
global $$conf['variable'];
}
$conditions = array(
'variable' => isset($conf['variable']) && (!isset($$conf['variable']) || !$$conf['variable']),
'hook_suffix' => isset($conf['hook_suffix']) && (is_null($hook_suffix) || $conf['hook_suffix'] != $hook_suffix)
);
return in_array(true, array_values($conditions), true);
}
Run Code Online (Sandbox Code Playgroud)
这对于这个:
if (isset($conf['variable'])) {
global $$conf['variable']; # What the heck is this?
}
Run Code Online (Sandbox Code Playgroud)
我可以检查PHP错误日志并在服务器上重现相同的错误:
PHP Parse error: syntax error, unexpected '[', expecting ',' or ';'
众所周知,这个WordPress主题在过去有效,但在过去的3年中似乎已被抛弃.
让我谈谈问题的核心:global $$conf['variable'];应该做些什么.我假设这是不推荐使用的代码,因为它之前已经有用了.