Home  >  Article  >  Backend Development  >  求解释这个函数是什么意思?该如何处理

求解释这个函数是什么意思?该如何处理

WBOY
WBOYOriginal
2016-06-13 12:43:40957browse

求解释这个函数是什么意思?

function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {<br>
	$return = '';<br>
	$matches = parse_url($url);<br>
	!isset($matches['host']) && $matches['host'] = '';<br>
	!isset($matches['path']) && $matches['path'] = '';<br>
	!isset($matches['query']) && $matches['query'] = '';<br>
	!isset($matches['port']) && $matches['port'] = '';<br>
	$host = $matches['host'];<br>
	$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';<br>
	$port = !empty($matches['port']) ? $matches['port'] : 80;<br>
	if($post) {<br>
		$out = "POST $path HTTP/1.0\r\n";<br>
		$out .= "Accept: */*\r\n";<br>
		//$out .= "Referer: $boardurl\r\n";<br>
		$out .= "Accept-Language: zh-cn\r\n";<br>
		$out .= "Content-Type: application/x-www-form-urlencoded\r\n";<br>
		$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";<br>
		$out .= "Host: $host\r\n";<br>
		$out .= 'Content-Length: '.strlen($post)."\r\n";<br>
		$out .= "Connection: Close\r\n";<br>
		$out .= "Cache-Control: no-cache\r\n";<br>
		$out .= "Cookie: $cookie\r\n\r\n";<br>
		$out .= $post;<br>
	} else {<br>
		$out = "GET $path HTTP/1.0\r\n";<br>
		$out .= "Accept: */*\r\n";<br>
		//$out .= "Referer: $boardurl\r\n";<br>
		$out .= "Accept-Language: zh-cn\r\n";<br>
		$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";<br>
		$out .= "Host: $host\r\n";<br>
		$out .= "Connection: Close\r\n";<br>
		$out .= "Cookie: $cookie\r\n\r\n";<br>
	}<br>
	if(function_exists('fsockopen')) {<br>
		$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);<br>
	} elseif (function_exists('pfsockopen')) {<br>
		$fp = @pfsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);<br>
	} else {<br>
		$fp = false;<br>
	}<br>
<br>
	if(!$fp) {<br>
		return '';<br>
	} else {<br>
		stream_set_blocking($fp, $block);// 让程序无阻塞<br>
		stream_set_timeout($fp, $timeout);<br>
		@fwrite($fp, $out);<br>
		$status = stream_get_meta_data($fp);//作用于读取流时的时间控制<br>
		if(!$status['timed_out']) {<br>
			while (!feof($fp)) {<br>
				if(($header = @fgets($fp)) && ($header == "\r\n" ||  $header == "\n")) { <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn