站长资讯网
最全最丰富的资讯网站

php怎么获取表单数据

php怎么获取表单数据

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); ?>

赞(0)
分享到: 更多 (0)