Site icon 时鹏亮的Blog

PHP-file_get_contents 设置POST数据方法

请知悉:本文最近一次更新为 7年 前,文中内容可能已经过时。

以下代码实现了post数据的功能,配合之前写的超时,就可以完成类似curl的功能了。

$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'content-type:application/x-www-form-urlencoded',
'content' => $postdata
)
);
$response = @file_get_contents($url, false, stream_context_create($opts));

如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《PHP-file_get_contents 设置POST数据方法》相关的博文:

Exit mobile version