临时设置时区
date_default_timezone_set('PRC');
获取当前毫秒数
function get_total_millisecond()
{
$time = explode (" ", microtime () );
$time = $time [1] . ($time [0] * 1000);
$time2 = explode ( ".", $time );
$time = $time2 [0];
return $time;
}
判断一个值是否为数组
is_array($value)
判断一个值是否为object
is_object($value)
curl 请求设置自定义请求头
$url = "http://10.150.132.2:8080/test";
$header = [];
$header[] = "Content-Type:application/json";
$header[] = "testId: 4sfdafdsaodakfdljaffsad";
$header[] = "timestamp:{$timestamp}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
$data = array('success'=>false, "msg" => curl_error($ch));
} else {
$data = json_decode(strtr($tmpInfo, array("\r"=>' ',"\t"=>' ')), true);
}
curl_close($ch);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)