Func将相对URL转换为Abs URL [英] Func to Turn Relative URLs into Abs URLs

查看:72
本文介绍了Func将相对URL转换为Abs URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi group,


我迫切需要一个函数,它将相对URL转换为< img>的SRC部分中的绝对URL。标签。


ie:


函数makeAbsolute($ html,$ basehref)

{

//如果正则表达式匹配=相对网址==>返回带有绝对URL的img标签

}


我已经搜索过谷歌,PHP.net,PHPClasses.org等,但已经

无法找到这样的功能。


因为我是关于RegEx的任何事的白痴,我一直是

我不能自己写这个功能。


如果有人有这样的功能,如果你能请的话我会很高兴

发布它。

hi group,

i desperately need a function that will transform relative URLs to
absolute URLs in the SRC part of <img> tags.

ie:

function makeAbsolute($html,$basehref)
{
//if regex match = relative URL ==> return img tag with absolute URL
}

i''ve scoured Google, PHP.net, PHPClasses.org, etc.., but have been
unable to find such a function.

since i''m an idiot regarding anything concerning RegEx, i''ve been
unable to write this function on my own.

if anyone has such a function, i''d be very glad if you could please
post it.

推荐答案

html,


basehref)

{

//如果正则表达式匹配=相对URL ==>返回带有绝对URL的img标签

}


我已经搜索过谷歌,PHP.net,PHPClasses.org等,但已经

无法找到这样的功能。


因为我是关于RegEx的任何事的白痴,我一直是

我不能自己写这个功能。


如果有人有这样的功能,如果你能请的话我会很高兴

发布它。

basehref)
{
//if regex match = relative URL ==> return img tag with absolute URL
}

i''ve scoured Google, PHP.net, PHPClasses.org, etc.., but have been
unable to find such a function.

since i''m an idiot regarding anything concerning RegEx, i''ve been
unable to write this function on my own.

if anyone has such a function, i''d be very glad if you could please
post it.


我迫切需要一个将相对URL转换为SRC部分的绝对URL的函数< IMG>标签。
i desperately need a function that will transform relative URLs to
absolute URLs in the SRC part of <img> tags.




此功能的用户注释中有几条建议

< http://www.php.net/realpath> ;。


---

史蒂夫



There are several suggestions in the user notes for this function
<http://www.php.net/realpath>.

---
Steve


这篇关于Func将相对URL转换为Abs URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆