您的位置:首頁/技術文章
文章詳情頁

php相對路徑轉化成絕對路徑

【字号: 作者:豬豬瀏覽:3日期:2024-02-24 16:39:27

提取 Gregarius中的一個函數??梢园丫W頁中的相對路徑自動轉化成絕對路徑。

<? 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='https://', 'href='http://www.wxshucaidpc.com/bcjs/21976.html'.$protocol[0].$server_url.'/', $content); $new_content = preg_replace('/src='https://', 'src='http://www.wxshucaidpc.com/bcjs/21976.html'.$protocol[0].$server_url.'/', $new_content); } else { $new_content = $content; } return $new_content; } ?>

標簽: PHP
国产综合久久一区二区三区