关于php:未定义的变量:使用HTML净化器时,purify和方法名称必须是字符串

Undefined variable: purify and method name must be a string while using HTML purifier

有错误的行:

1
$msg = $purifier->$purify($result['Message']);

错误:

1
Notice: Undefined variable: purify in /storage/ssd5/777/1537777/public_html/inc/ticketBody.php on line 41

1
Fatal error: Uncaught Error: Method name must be a string in /storage/ssd5/777/1537777/public_html/inc/ticketBody.php:41 Stack trace: #0 {main} thrown in /storage/ssd5/777/1537777/public_html/inc/ticketBody.php on line 41

配置:

1
2
3
4
require_once '../HTMLPurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'div, *[style|class]');
$purifier = new HTMLPurifier($config);

我不明白是什么问题…


它应该是: </P >

$purifier->purify($result['Message']); </P >

作为参考的文档,而不是 </P >

1
$purifier->$purify($result['Message']);

你做不有一个$purify变declared,hence的错误。 </P >

P。S:初始的语法是有效的,因为你可能想要的动态呼叫这个方法,检查 </P >