0

我有一个关于一个众所周知的问题的问题:我的用户的消息包含指向我网站其他区域的超链接。我从数据库中获取数据以显示用户在其个人资料上发布的最后一条消息。这有效,但我看不到超链接。我只是将它们视为纯文本。我怎样才能使这些东西成为应有的超链接?

我用这个例如:

$lastpost = execute_scalar("SELECT message FROM messages where messages.user='$who' Order by date desc");

@Prasath Albert 给你:

    $message = preg_replace("'\look here: (.*)\)'Ui","(look here: <a href=\"haha.php?&q=\\1\">\\1</a>)",$message);
4

1 回答 1

0

使用此链接

用 HTML 链接替换文本中的 URL

http://zenverse.net/php-function-to-auto-convert-url-into-hyperlink/

于 2012-10-11T09:17:45.353 回答