php中如何用模式匹配的方法从已知url中取出domain部分? 使用php的全局变量:$HTTP_SERVER_VARS["HTTP_HOST"] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 www.domain.com/xx/xxx 取得domain?得到url字符串,然后根据“.”的分割取得domain的值 www.domain.com/xx/xxx 取得domain?得到url字符串,然后根据“.”的分割取得domain的值 试试这个:$surl=split("[\.]",$url);$domain=$surl[1]; $domain = substr($url,0,strpos($str,'/')); to:darzui(牛肉饭) 以当前url为例,按点分割只能取出csdn。而我想得到www.csdn.net。to:qsnake(在家过年中) $str是什么? 把.改为/$surl=split("[\/]",$url);$domain=$surl[1]; 我想你想取得是 www.domain.com 而不是domain注意 url 的情况,有可能是 www.domain.com/xx/xxx 但有可能是 http://www.domain.com/xx/xxx ftp://www.domain.com/xx/xxx不同情况需要考虑到 $url = preg_replace('/^http:\\/\\//i', '', $url);去掉http://部分,然后你们自己看着办吧 【赋值】PHP 参数、变量赋值为空的问题 翻页post参数丢失如何解决? PHP和MySQL Web开发电子书及源码 为学习PHP的朋友准备 请问php 中sqlite_open 问题 php ajax 乱码的问题。 点击按钮说是缺少对象 爬人人网好友遇到的模拟登陆问题 很怪的错误??????? [ SQL ] 关于Left Join 的用法 foreach 循环的问题,请帮忙! Win2000中可否使用Apache服务器? 一个问题:)
得到url字符串,然后根据“.”的分割取得domain的值
得到url字符串,然后根据“.”的分割取得domain的值
$surl=split("[\.]",$url);
$domain=$surl[1];
以当前url为例,按点分割只能取出csdn。而我想得到www.csdn.net。to:qsnake(在家过年中)
$str是什么?
把.改为/
$surl=split("[\/]",$url);
$domain=$surl[1];
注意 url 的情况,有可能是
www.domain.com/xx/xxx
但有可能是 http://www.domain.com/xx/xxx ftp://www.domain.com/xx/xxx
不同情况需要考虑到
去掉http://部分,然后你们自己看着办吧