我在两个站点上遇到以下错误:
致命错误:未捕获错误:函数名称必须为字符串 /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";
}
}
}
答案 0 :(得分:0)
检查变量is a string,不仅是设置了变量,而且还明确是字符串。
if(is_string($rule['key']) && method_exists($this, $rule['key']) && $rule['value'] != "")
写时短一些,参数少一个。无论如何,这都会强制该值为字符串。如果您希望这样做,则取决于您的代码库。
if(method_exists($this, (string)$rule['key']) && $rule['value'] != "")