【问题标题】:Grab Posts Content from Database with hyperlink - PHP使用超链接从数据库中获取帖子内容 - PHP
【发布时间】:2013-06-12 00:26:53
【问题描述】:

大家好, 我想知道如何使用 Anchor 标签从数据库中获取内容。例如,我已经在网站上发布了帖子。

Hello I am the PHP.go from here http://php.net

现在,当我从数据库中获取数据时,我想将 php.net 显示为链接。 像这样……

你好我是 PHP.go 从这里http://php.net

如何使用 php..

如果有任何相关的教程,视频..在这里发布.. :D

【问题讨论】:

    标签: php mysql pdo hyperlink anchor


    【解决方案1】:

    你可以使用regular expression

    $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;
    

    【讨论】:

    • 它显示此错误解析错误:语法错误,意外'$pattern' (T_VARIABLE) in
    • $text结尾需要分号
    猜你喜欢
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    • 2014-11-13
    • 1970-01-01
    • 2014-04-05
    • 1970-01-01
    • 2014-06-20
    • 1970-01-01
    相关资源
    最近更新 更多