我下面的腳本,超鏈接貼在我的網站的任何鏈接:自動超鏈接添加額外的HTTP://到開頭?
$text = trim($text);
while ($text != stripslashes($text)) { $text = stripslashes($text); }
$text = strip_tags($text,"<b><i><u>");
$text = preg_replace("/(?<!http:\/\/)www\./","http://www.",$text);
$text = preg_replace("/((http|ftp)+(s)?:\/\/[^<>\s]+)/i", "<a href=\"\\0\" target=\"_new\">\\0</a>",$text);
然而,出於某種原因,如果我添加了一個鏈接https://www.test.com
它結束了顯示這樣的 - https://http://www.test.com
- 我究竟做錯了什麼?我怎樣才能使它與https鏈接一起工作呢?它可以正常使用http鏈接。謝謝! :-)
可能重複[需要一個很好的正則表達式來將URL轉換爲鏈接,但保留現有的鏈接](http://stackoverflow.com/questions/287144/need-a-good-regex-to-convert-urls-to -links-but-leave-existing-links-alone) – hek2mgl