douwang9650 2016-02-18 13:21
浏览 6
已采纳

PHP - 删除字符并连接另一个字符的函数(也称为相对于绝对URL的转换)

I have a phpbb external script which outputs a relative url

(like ./forum/viewtopic.php?f=xx&t=xx),

but for making an rss feed I need the absolute url

(http://example.com/forum/viewtopic.php?f=xx&t=xx) to use.

My question is: How could I make this?

I suppose it should just be a string function, to replace the first dot and then concatenate the http://example.com before it, but I don't have enough php skills to do that.

  • 写回答

1条回答 默认 最新

  • dongshungai4857 2016-02-18 13:23
    关注

    Simply replace your ./ with the hostname.

    $url = str_replace('./', 'http://example.com/', $url);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部