手机
当前位置:查字典教程网 >编程开发 >php教程 >相对路径转化成绝对路径
相对路径转化成绝对路径
摘要:提取Gregarius中的一个函数。可以把网页中的相对路径自动转化成绝对路径。

提取Gregarius中的一个函数。可以把网页中的相对路径自动转化成绝对路径。

<?

functionrelative_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;

}

?>

【相对路径转化成绝对路径】相关文章:

从零开始 教你如何搭建Discuz!4.1论坛(图)

PHP中把对象转换为关联数组代码分享

Apache2的httpd.conf翻译

php中set_error_handler的用法总结

一个用php3编写的简单计数器

php eval函数一句话木马代码

用libtemplate实现静态网页生成

php获取json数据所有的节点路径

复杂检索数据并分页显示的处理方法

PHP调用三种数据库的方法(1)

精品推荐
分类导航