欧美无砖专区一中文字新闻,超级吹潮高手喷40秒视频,宝贝你真湿真紧好爽h视频男男,水牛在线成人无码AV

php curl,php之curl設(shè)置超時實例?

用戶投稿 410 0

關(guān)于“php_curl不是”的問題,小編就整理了【2】個相關(guān)介紹“php_curl不是”的解答:

php之curl設(shè)置超時實例?

PHP CURL超時設(shè)置分兩種,毫秒跟秒都是可以的。

curl普通秒級超時:

$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$url)

;curl_setopt($ch, CURLOPT_RETURNTRANSFER,1)

;curl_setopt($ch, CURLOPT_TIMEOUT,60)

; //只需要設(shè)置一個秒的數(shù)量就可以curl_setopt($ch, CURLOPT_HTTPHEADER, $headers)

;curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT'])

;curl普通秒級超時使用:

curl_setopt($ch, CURLOPT_TIMEOUT,60)

;curl如果需要進行毫秒超時,需要增加:curl_easy_setopt(curl, CURLOPT_NOSIGNAL,1L)

;//或者curl_setopt ( $ch, CURLOPT_NOSIGNAL,true)

;//支持毫秒級別超時設(shè)置

如何使用php中的curl方法向服務(wù)器發(fā)送post請求?

用PHP向服務(wù)器發(fā)送HTTP的POST請求,代碼如下:

<?php/** * 發(fā)送post請求 * @param string $url 請求地址 * @param array $post_data post鍵值對數(shù)據(jù) * @return string */ function send_post($url, $post_data) { $postdata = http_build_query($post_data); $options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 15 * 60 // 超時時間(單位:s) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; }

到此,以上就是小編對于“php_curl不是”的問題就介紹到這了,希望介紹關(guān)于“php_curl不是”的【2】點解答對大家有用。

抱歉,評論功能暫時關(guān)閉!