PHP sending variables to file_get_contents()

前端 未结 5 621
梦如初夏
梦如初夏 2020-12-07 00:59

I want to be able to send a few variables to a file through file_get_contents().

This is firstfile.php:



        
5条回答
  •  情歌与酒
    2020-12-07 01:25

    The following code snippet shows an easy way how to send a HTTP post request using the PHP function file_get_contents:

     'value1', 'param2' => 'value2')
    
    // use key 'http' even if you send the request to https://...
    $options = array('http' => array(
        'method'  => 'POST',
        'content' => http_build_query($data)
    ));
    
    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    
    print_r($result);
    

    OR Passing variable in a URL (php) & file_get_contents()

提交回复
热议问题