我有一個網站是用戶輸入文章和他們的參考(如維基百科)。保存在數據庫中的參考文獻包括網址和非網址。目前,我使用谷歌搜索?q及其正常工作來超鏈接腳本。如何超鏈接的網址或非網址在php
echo("<br><a rel=nofollow target=_blank href='http://www.google.com/search?q=".urlencode($row['ref'])."' class=art>$row[ref]</a>");
我想知道是否它能夠自動地檢測我的引用作爲一個網址或不是。如果是一個網絡地址,然後當用戶點擊超鏈接直接進入該網站,如果沒有它應該超鏈接到谷歌搜索。
例如:
如果用戶輸入該鏈接作爲reference.hyper鏈路應該是此網絡地址
http://www.washingtonpost.com/sports/capitals
or
www.washingtonpost.com/sports/capitals
or
washingtonpost.com/sports/capitals
,或者如果用戶輸入的參考如下
washingtonpost+sports+capitals
它應該去谷歌搜索?q
提前感謝您的幫助