我想在我的模块前端的magento中创建链接,有一个评论框,所以我想如果任何客户或客人在评论中使用任何url,那么它将显示为链接,所以如何创建它,请给我一个如何做这个的例子
<?php
$string = 'I have some texts here and also links such as http://www.youtube.com http://www.haha.com and lol@example.com. They are ready to be replaced.';
function makeClickableLinks($s) {
return preg_replace('@(https?://([-w.]+[-w])+(:d+)?(/([w/_.#-]*(?S+)?[^.s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
}
echo makeClickableLinks($string);
?>
这个答案指的是这个链接https://stackoverflow.com/a/3525863/2522817