相對路徑轉(zhuǎn)化成絕對路徑
更新時(shí)間:2007年04月10日 00:00:00 作者:
提取 Gregarius中的一個(gè)函數(shù)??梢园丫W(wǎng)頁中的相對路徑自動(dòng)轉(zhuǎn)化成絕對路徑。
<?
function relative_to_absolute($content, $feed_url) {
preg_match('/(http|https|ftp):\/\//', $feed_url, $protocol);
$server_url = preg_replace("/(http|https|ftp|news):\/\//", "", $feed_url);
$server_url = preg_replace("/\/.*/", "", $server_url);
if ($server_url == '') {
return $content;
}
if (isset($protocol[0])) {
$new_content = preg_replace('/href="\//', 'href="'.$protocol[0].$server_url.'/', $content);
$new_content = preg_replace('/src="\//', 'src="'.$protocol[0].$server_url.'/', $new_content);
} else {
$new_content = $content;
}
return $new_content;
}
?>
<?
function relative_to_absolute($content, $feed_url) {
preg_match('/(http|https|ftp):\/\//', $feed_url, $protocol);
$server_url = preg_replace("/(http|https|ftp|news):\/\//", "", $feed_url);
$server_url = preg_replace("/\/.*/", "", $server_url);
if ($server_url == '') {
return $content;
}
if (isset($protocol[0])) {
$new_content = preg_replace('/href="\//', 'href="'.$protocol[0].$server_url.'/', $content);
$new_content = preg_replace('/src="\//', 'src="'.$protocol[0].$server_url.'/', $new_content);
} else {
$new_content = $content;
}
return $new_content;
}
?>
相關(guān)文章
PHP與MySQL開發(fā)中頁面出現(xiàn)亂碼的一種解決方法
PHP與MySQL開發(fā)中頁面出現(xiàn)亂碼的一種解決方法...2007-07-07PHP提示Notice: Undefined variable的解決辦法
今天在調(diào)試程序的時(shí)候,很多網(wǎng)上提供的源碼都會(huì)出現(xiàn) Undefined variable錯(cuò)誤,一般情況下php是不需要定義變量的,但如果服務(wù)器什么都報(bào)錯(cuò)的,就會(huì)出現(xiàn)錯(cuò)誤,所以服務(wù)器上都是應(yīng)該屏蔽這種錯(cuò)誤的2012-11-11實(shí)現(xiàn) win2003 下 mysql 數(shù)據(jù)庫每天自動(dòng)備份
這篇文章主要為大家介紹下,如果用批處理實(shí)現(xiàn)mysql的自動(dòng)備份,需要的朋友可以參考下2006-12-12php實(shí)現(xiàn)點(diǎn)擊可刷新驗(yàn)證碼
這篇文章主要介紹了php如何實(shí)現(xiàn)點(diǎn)擊即可刷新驗(yàn)證碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2015-11-11PHP正則匹配中英文、數(shù)字及下劃線的方法【用戶名驗(yàn)證】
這篇文章主要介紹了PHP正則匹配中英文、數(shù)字及下劃線的方法,可用于針對用戶名的驗(yàn)證操作,需要的朋友可以參考下2017-08-08微信公眾號(hào)用戶與網(wǎng)站用戶的綁定解決方案分析
這篇文章主要介紹了微信公眾號(hào)用戶與網(wǎng)站用戶的綁定解決方案,結(jié)合實(shí)例形式分析了微信公眾號(hào)用戶與網(wǎng)站用戶綁定的原理、操作步驟、技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下2019-04-04PHP實(shí)現(xiàn)QQ空間自動(dòng)回復(fù)說說的方法
這篇文章主要介紹了PHP實(shí)現(xiàn)QQ空間自動(dòng)回復(fù)說說的方法,涉及php基于curl調(diào)用自動(dòng)回復(fù)接口的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12PHP實(shí)現(xiàn)獲取ip地址的5種方法,以及插入用戶登錄日志操作示例
這篇文章主要介紹了PHP實(shí)現(xiàn)獲取ip地址的5種方法,以及插入用戶登錄日志操作,結(jié)合實(shí)例形式總結(jié)分析了php獲取訪客IP地址的5種常見操作方法,以及將用戶登陸信息寫入登陸日志數(shù)據(jù)庫相關(guān)操作技巧,需要的朋友可以參考下2019-02-02