php获取表单数据的几种方法:
一、用file_get_contents以get方式获取内容,需要输入内容为:
<?php $url='http://www.domain.com/?para=123'; $html = file_get_contents($url); echo $html; ?>
二、用file_get_contents函数,以post方式获取url,需要输入内容为:
<?php $url = 'http://www.domain.com/test.php?id=123'; $data = array ('foo' => 'bar'); $data = http_build_query($data); $opts = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencodedrn" . "Content-Length: " . strlen($data) . "rn", 'content' => $data ) ); $ctx = stream_context_create($opts); $html = @file_get_contents($url,'',$ctx); ?>