【发布时间】:2013-06-12 02:59:53
【问题描述】:
看看这个并帮我解决这个问题..这不起作用..
$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
【问题讨论】:
-
添加一个;在第一行的末尾
标签: php regex hyperlink anchor syntax-error