php獲取表單數(shù)據(jù)的幾種方法:
一、用file_get_contents以get方式獲取內(nèi)容,需要輸入內(nèi)容為:
<?php $url='http://www.domain.com/?para=123'; $html = file_get_contents($url); echo $html; ?>
二、用file_get_contents函數(shù),以post方式獲取url,需要輸入內(nèi)容為:
<?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); ?>