导航:首页 > 配服务器 > php服务器url地址

php服务器url地址

发布时间:2025-02-13 13:04:22

php获取url参数

1、在当前网页echo出变量$_SERVER['HTTP_HOST']即可获取域名或主机地址。

② ThinkPHP 网址格式URL地址怎么设置

thinkPHP的URL在config中配置

一、URL规则

1、默认是区分大小写的

2、如果我们不想区分大小写可以改配置文件

'URL_CASE_INSENSITIVE'=>true,//url不区分大小写

3、如果模块名为 UserGroupAction,那么url找模块就必要要写成

http://localhost/thinkphp4/index.php/user_group/index

4、如果'URL_CASE_INSENSITIVE'=>false,那么url也可以写为

http://localhost/thinkphp4/index.php/UserGroup/index

二、URL伪静态

'URL_HTML_SUFFIX'=>'html|shtml|xml',//限制伪静态的后缀

三、URL路由

1、启动路由
要在配置文件中开启路由支持
'URL_ROUTER_ON'=>ture//开启路由

2、使用路由

1.规则表达式配置路由

'URL_ROUTE_RULES'=>array()//路由规则
'my'=>'Index/index',//静态地址路由
'my'=>'/Index/index',//静态地址路由,加/直接跳到网站根目录下。
':id/:num'=>'Index/index',//动态地址路由,可以$_GET接收地址栏参数
'year/:year/:month/:date'=>'Index/index',//动态和静态混合地址路由
'year/:yeard/:monthd/:dated'=>'Index/index',//动态和静态混合地址路由加上d代表类型只能是数字
'my/:id$'=>'Index/index',//加上$说明地址中只能是my/1000后面不能有其他内容了

2.正则表达式配置路由,必须以/开始 /结束

'/^year/(d{4})/(d{2})/(d{2})/'=>'Index/index?year=:1&month=:2&date=:3'//这里d表示必须是数字

③ php打开URL的几种方法

PHP中打开URL地址的几种方法总结,这里的函数主要用于小偷采集等函数。
1:用file_get_contents
以get方式获取内容
复制代码代码如下:

<?php
$url='http://www..com/';

$html=file_get_contents($url);
//print_r($http_response_header);

ec($html);
printhr();
printarr($http_response_header);

printhr();
?>

示例代码2:用fopen打开url,
以get方式获取内容
复制代码代码如下:

<?
$fp=fopen($url,'r');

printarr(stream_get_meta_data($fp));
printhr();
while(!feof($fp)){

$result.=fgets($fp,1024);
}
echo"urlbody:$result";

printhr();
fclose($fp);
?>


示例代码3:用file_get_contents函数,以post方式获取url
复制代码代码如下:

<?php
$data=array('foo'=>
'bar');
$data=http_build_query($data);
$opts=array(
'http'
=>array(
'method'=>'POST',
'header'=>"Content-type:
application/x-www-form-urlencoded".
"Content-Length:".strlen($data).
"",
'content'=>$data
),
);
$context=
stream_context_create($opts);
$html=
file_get_contents('http://localhost/e/admin/test.html',false,$context);

echo$html;
?>


示例代码4:用fsockopen函数打开url,以get方式获取完整的数据,包括header和body
复制代码代码如下:

<?
functionget_url
($url,$cookie=false){
$url=parse_url($url);
$query=
$url[path]."?".$url[query];
ec("Query:".$query);
$fp=fsockopen(
$url[host],$url[port]?$url[port]:80,$errno,$errstr,30);
if(!$fp){

returnfalse;
}else{
$request="GET$queryHTTP/1.1";

$request.="Host:$url[host]";
$request.="Connection:Close";

if($cookie)$request.="Cookie:$cookie ";
$request.="";

fwrite($fp,$request);
while(!@feof($fp)){
$result.=@fgets($fp,
1024);
}
fclose($fp);
return$result;
}
}

//获取url的html部分,去掉header
functionGetUrlHTML($url,$cookie=false){

$rowdata=get_url($url,$cookie);
if($rowdata)
{
$body=
stristr($rowdata,"");
$body=substr($body,4,strlen($body));
return$body;

}
returnfalse;
}

?>

阅读全文

与php服务器url地址相关的资料

热点内容
php压缩图片内存大小 浏览:493
在哪里可以查看云服务器的信息 浏览:68
python读取非txt文件 浏览:797
艾莫迅用什么编程软件好 浏览:225
android文件存储读取 浏览:214
php基础教程第5版 浏览:543
服务器里面怎么刷东西 浏览:194
荣耀手机如何快速把app切换页面 浏览:796
傻瓜式php源码 浏览:357
非那根剂量计算法 浏览:91
开云服务器怎么申请 浏览:815
安卓从哪看什么时候开始使用 浏览:506
php取文本长度 浏览:410
公交车供电电压转为单片机 浏览:106
电流单片机 浏览:124
算法中ceil代表什么 浏览:491
内核源码超频 浏览:226
怎样把图片文件夹转化为压缩包 浏览:462
程序员概率题 浏览:268
东营银行app限额在哪里设置 浏览:483