<p>相对路径转化成绝对路径</p> <p>&lt;?<br /> function relative_to_absolute($content, $feed_url) { <br /> preg_match('/(http|https|ftp):///', $feed_url, $protocol); <br /> $server_url = preg_replace(&quot;/(http|https|ftp|news):///&quot;, &quot;&quot;, $feed_url);<br /> $server_url = preg_replace(&quot;//.*/&quot;, &quot;&quot;, $server_url); <br /> if ($server_url == '') { <br /> return $content; <br /> } <br /> if (isset($protocol[0])) {<br /> $new_content = preg_replace('/href=&quot;//', 'href=&quot;'.$protocol[0].$server_url.'/', $content); <br /> $new_content = preg_replace('/src=&quot;//', 'src=&quot;'.$protocol[0].$server_url.'/', $new_content); <br /> } else { <br /> $new_content = $content; <br /> } <br /> return $new_content; <br /> } <br /> ?&gt;<br /> </p>
T:0.006670s,M:244.92 KB
返回顶部 留言