这里我就不废话了直接上代码,一般做开发的一看就懂哈哈。
$url="http://www.32e.top"; $context = stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => "Content-type: application/json;charset=utf-8", 'content' => json_encode($data), 'timeout' => 20, ) )); file_get_contents($url, false, $context); 上面post的是json 如果data是数组的话用 'content' => http_build_query($data),是不是感觉比curl简单很多,如果需要不是很高的话使用file_get_contents函数是比较快捷的,可以少些很多代码哦,赶快试试吧。
除特别注明外,本站所有文章均为博文家原创,转载请注明出处来自https://www.32e.top/develop/php/article-17.html
暂无评论