首页 > 解决方案 > 如何修复(不能在第 214 行的 /Timber/functions/functions-twig.php 中使用 $this 作为参数)

问题描述

致命错误:不能在第 214 行的 /www/webvol14/pn/nlr3fq63bvk0q48/skywork.se/public_html/wp-content/themes/startup/vendor/Timber/functions/functions-twig.php 中使用 $this 作为参数

网站:php 7.1

/**
 * @param mixed $this
 * @return string
 */
function twig_get_class($this) {
    return get_class($this);
}

/**
 * @param mixed $this
 * @return string
 */
function twig_get_type($this) {
    return gettype($this);
}

标签: phpwordpresstimber

解决方案


如php手册中所述:

警告 请注意,变量变量不能在函数或类方法中与 PHP 的超全局数组一起使用。变量 $this 也是一个不能动态引用的特殊变量。

https://www.php.net/manual/en/reserved.variables.globals.php#120071


推荐阅读