GET Request from PHP using file_get_contents with parameters

前端 未结 1 1202
独厮守ぢ
独厮守ぢ 2020-12-06 11:20

I want to send a GET request to an external site, but also want to send some parameters

for example i\'ve to send a get request to example.com

i want to exec

相关标签:
1条回答
  • 2020-12-06 11:43

    The content option is used with POST and PUT requests. For GET you can just append it as a query string:

    file_get_contents('http://example.com/send.php?'.$getdata, false, $context);
    

    Furthermore, the method defaults to GET so you don't even need to set options, nor create a stream context. So, for this particular situation, you could simply call file_get_contents with the first parameter if you wish.

    0 讨论(0)
提交回复
热议问题