-2

我有以下代码行一直给我这个错误:

Parse error: syntax error, unexpected '[' php

对于这一行:

$str = removeTags($str, ['script', 'style']);

为什么我会收到这个错误?我在网上看到可能是因为我没有最新的php版本?网站在 wordpress 中运行。

4

1 回答 1

4

您需要 PHP >= 5.4.0 的[]语法。利用:

$str = removeTags($str, array('script', 'style'));
于 2014-09-02T16:06:34.527 回答