php 的file_get_contents模拟表单(POST / GET方式提交)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 的file_get_contents模拟表单(POST / GET方式提交)相关的知识,希望对你有一定的参考价值。
function post_to($vars, $http){
$context = array(
'http'=>array(
'timeout'=> 20,
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen($vars)."\r\n",
'content'=> $vars )
);
$xcontext = stream_context_create($context);
$ret = @file_get_contents($http,false,$xcontext);
return $ret;
}
function get_to($http){
$context = array(
'http'=>array(
'timeout'=> 20,
'method' => 'GET',
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
)
);
$xcontext = stream_context_create($context);
$ret = @file_get_contents($http, false, $xcontext);
return $ret;
}
以上是关于php 的file_get_contents模拟表单(POST / GET方式提交)的主要内容,如果未能解决你的问题,请参考以下文章
php 操作数据类库 模拟Thinkphp操作方法实现
php 操作数据类库 模拟Thinkphp操作方法实现
php+mysql 模拟队列发送邮件
2021 HDU多校 Boring data structure problem 链表模拟
2021 HDU多校 Boring data structure problem 链表模拟
将变量从一个表传递到另一个 PHP 页面中的另一个 [重复]