【问题标题】:href Hyperlink,Anchor Tage regular expression php error [closed]href超链接,锚标记正则表达式php错误[关闭]
【发布时间】: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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-11
    • 1970-01-01
    • 2023-03-07
    • 2013-11-27
    • 2012-12-01
    • 2011-04-19
    • 1970-01-01
    相关资源
    最近更新 更多