-2

看看这个并帮助我将其修复为工作..这不起作用..

$text = "Hello I am the PHP.go from here http://php.net"
$pattern = "/http:\/\/(www\.)?([^.]+\.[^.\s]+\.?[^.\s]*)/i";
$replace = "<a href='http://\\1\\2'>http://\\1\\2</a>";
$string =  preg_replace($pattern,$replace,$text);
echo $string;

这是它显示的错误。

 Parse error: syntax error, unexpected '$pattern' (T_VARIABLE) in
4

1 回答 1

1

如果您的代码如此处所写,则您在 $text 末尾缺少一个分号。

于 2013-06-15T16:55:11.960 回答