file_get_contens发送post请求

$postdata = http_build_query(
    array(
        'var1' => 'some content',
        'var2' => 'doh'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-Type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://example.com/submit.php', false, $context);

看到这里你可以会问那既然file_get_content可以做那么多事情还使用cur干什么?
https://www.cnblogs.com/lis2/p/16067882.html

posted @ 2022-03-28 16:47  小刘的早餐店  阅读(55)  评论(0编辑  收藏  举报