helo everyone
这是我买的一本书上的代码。它给出了下面的错误。
语法错误,意外的T_STRING,应为T_PAAMAYIM_NEKUDOTAYIM
preg_match (‚#<!-- START ‚. $tag . ‚ -->(.+?)<!-- END ‚.$tag . ‚ -->#si', $this->content, $tor);
$tor = str_replace (‚<!-- START ‚. $tag . ‚ -->', „", $tor[0]);
$tor = str_replace (‚<!-- END ‚ . $tag . ‚ -->', „", $tor);preg_match就是这条线。有人能帮我解决这个问题吗?
发布于 2011-02-27 22:40:35
我认为您只是复制了使用typographic quotation marks而不是“简单”引号"和'的代码示例。代码应为:
preg_match ('#<!-- START '. $tag . ' -->(.+?)<!-- END '.$tag . ' -->#si', $this->content, $tor);
$tor = str_replace ('<!-- START '. $tag . ' -->', "", $tor[0]);
$tor = str_replace ('<!-- END ' . $tag . ' -->', "", $tor);发布于 2011-02-27 22:37:36
在PHP中,字符串由引号分隔(双引号或单引号)。
在这里,您使用了某种逗号作为字符串分隔符--这是错误的,并解释了语法错误。
有关更多信息,作为参考,您应该查看。
我想你应该使用这样的东西:
preg_match ('#<!-- START '. $tag . ' -->(.+?)<!-- END '.$tag . ' -->#si', $this->content, $tor);
$tor = str_replace ('<!-- START '. $tag . ' -->', '', $tor[0]);
$tor = str_replace ('<!-- END ' . $tag . ' -->', '', $tor);https://stackoverflow.com/questions/5133773
复制相似问题