急需php模拟post的详细代码,有详细的注释了,有例子最好了

来源:百度知道 编辑:UC知道 时间:2024/06/22 02:14:11
php 模拟 post 这事我找的代码,急需读懂,高手请进!
应为想用,所以请高手不吝指导下,能够解释下的话最好了,非常感谢!
<?php
$URL = '';
$post_data['SysID'] = $_POST['SysID'];
$post_data['FuncID'] = $_POST['FuncID'];
$post_data['LoginID'] = $_POST['LoginID'];
$post_data['LoginKey'] = $_POST['LoginKey'];
$referrer="";
$URL_Info=parse_url($URL);
if($referrer=="")
{
$referrer=$_SERVER["SCRIPT_URI"];
}
foreach ($post_data as $key=>$value)
{
$values[]="$key=".urlencode($value);
}

$data_string=implode("&",$values);
// Find out which port is needed - if not given use standard (=80)
if (!isset($URL_Info["port"])) {
$URL_Info["port"]=80;
// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host:

其实这段代码并不难理解,本人表达能力不佳,见谅
<?php

$URL = ''; //需要提交到的页面
//下面这段是要提交的数据
$post_data['SysID'] = $_POST['SysID'];
$post_data['FuncID'] = $_POST['FuncID'];
$post_data['LoginID'] = $_POST['LoginID'];
$post_data['LoginKey'] = $_POST['LoginKey'];
$referrer="";
$URL_Info=parse_url($URL);
if($referrer=="")
{
$referrer=$_SERVER["SCRIPT_URI"];
}
foreach ($post_data as $key=>$value)
{
$values[]="$key=".urlencode($value);
}

$data_string=implode("&",$values);//提交的数据格式是 a=1&b=2
// Find out which port is needed - if not given use standard (=80)
if (!isset($URL_Info["port"])) {
$URL_Info["port"]=80;
// building POST-request:
//一般做网站用form提交数据后,之后的操作就不用我们不管了,
//这里就是在模拟POST操作的HTTP头,具体的可以去查HTTP协议的资料,并不复杂
$request.="POST &qu