我在两个网站上遇到以下错误:
致命错误:未捕获错误:函数名称必须是/home/lanesra2/public_html/wp-content/themes/Lanesra/framework/php/class-style-generator.php:123中的字符串堆栈跟踪:#0 / home / lanesra2 /public_html/wp-includes/class-wp-hook.php(286):
我已经多年没有登录这些网站了,你可以看到它们都建立在WordPress上。任何可以修复它的潜在变化?
这也是代码:
{
foreach($this->rules as $rule)
{
$rule['value'] = str_replace('{{AVIA_BASE_URL}}', AVIA_BASE_URL, $rule['value']);
$rule['value'] = preg_replace('/(http|https):\/\//', '//', $rule['value']);
//check if a executing method was passed, if not simply put the string together based on the key and value array
if(isset($rule['key']) && method_exists($this, $rule['key']) && $rule['value'] != "")
{
$this->output .= $this->$rule['key']($rule)."\n";
}
else if($rule['value'] != "")
{
$this->output .= $rule['elements']."{\n".$rule['key'].":".$rule['value'].";\n}\n\n";
}
}
}
检查变量is a string,不仅仅是它被设置,而且具体地说它也是一个字符串。
if(is_string($rule['key']) && method_exists($this, $rule['key']) && $rule['value'] != "")
写入略短,少一个参数。无论如何,这会强制值为字符串;这取决于您的代码库,如果这是您的需要。
if(method_exists($this, (string)$rule['key']) && $rule['value'] != "")