原始问题:
用php写一个curl函数
用php写一个curl函数的示例代码如下:
<?php
// 初始化一个cURL会话
$ch = curl_init();
// 设置需要抓取的URL
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/');
// 设置HTTP头字段的数组
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); // 返回原生的(Raw)输出 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 执行一个cURL会话并且获取相关回复 $response = curl_exec($ch); // 关闭 cURL 释放资源 curl_close($ch); ?>
Prev:龙煤集团盈亏报告