使用php模拟post传值虽然在日常生活中用到的不是很多,但是在某些场合还是经常用到的。下面小编给大家整理了三种php模拟post传值的方法,file_get_contents、curl和socket。
第一种:file_get_contents来模拟post
<phpfunction file_get_contents_post($url, $post){$options = array(‘http‘=> array(‘method‘=>‘POST‘,‘content‘=> http_build_query($post),),);$result = file_get_contents($url,false, stream_context_create($options));return $result;}$data = file_get_contents_post("http://';//$post_data = array();$res = $this->request_post($url, $post_data); print_r($res);}