如何从这种URL获取主机名? [英] How to get host name from this kind of URL?

查看:167
本文介绍了如何从这种URL获取主机名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从主机名和内部URL获取主机名.该怎么做.

I want to get host name from and inner URL. how to take that.

例如:-这是内部url格式.. http://hostname.com/folder/folder2/test.php?id=243432432424243

eg :- this is the inner url format .. http://hostname.com/folder/folder2/test.php?id=243432432424243

如何使用php从上述URL中获取http://hostname.com?

How to take the http://hostname.com from the above URL using php?

推荐答案

使用 parse_url .

您需要输出数组的'scheme''host'元素(也许还有'port''user''password'-您可以使用

You want the 'scheme' and 'host' elements of the output array (and maybe 'port', 'user' and 'password' as well - you can use http_build_url to stick these bits together if you want).

这篇关于如何从这种URL获取主机名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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