src/Utility/Utility.php
public static function getHeaderFromUrl($url) {
		// @codingStandardsIgnoreStart
		$url = @parse_url($url);
		// @codingStandardsIgnoreEnd
		if (empty($url)) {
			return false;
		}

		$url = array_map('trim', $url);
		$url['port'] = (!isset($url['port'])) ? '' : (':' . (int)$url['port']);
		$path = (isset($url['path'])) ? $url['path'] : '';

		if (empty($path)) {
			$path = '/';
		}

		$path .= (isset($url['query'])) ? "?$url[query]" : '';

		$defaults = [
			'http' => [
				'header' => "Accept: text/html\r\n" .
					"Connection: Close\r\n" .
					"User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64)\r\n",
			]
		];
		stream_context_get_default($defaults);

		if (isset($url['host']) && $url['host'] !== gethostbyname($url['host'])) {
			$url = "$url[scheme]://$url[host]$url[port]$path";
			$headers = get_headers($url);
			if (is_array($headers)) {
				return $headers;
			}
		}
		return false;
	}
public static function getHeaderFromUrl($url) {
		// @codingStandardsIgnoreStart
		$url = @parse_url($url);
		// @codingStandardsIgnoreEnd
		if (empty($url)) {
			return false;
		}

		$url = array_map('trim', $url);
		$url['port'] = (!isset($url['port'])) ? '' : (':' . (int)$url['port']);
		$path = (isset($url['path'])) ? $url['path'] : '';

		if (empty($path)) {
			$path = '/';
		}

		$path .= (isset($url['query'])) ? "?$url[query]" : '';

		$defaults = [
			'http' => [
				'header' => "Accept: text/html\r\n" .
					"Connection: Close\r\n" .
					"User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64)\r\n",
			]
		];
		stream_context_get_default($defaults);

		if (isset($url['host']) && $url['host'] !== gethostbyname($url['host'])) {
			$url = "$url[scheme]://$url[host]$url[port]$path";
			$headers = get_headers($url);
			if (is_array($headers)) {
				return $headers;
			}
		}
		return false;
	}
public static function getHeaderFromUrl ( $ url ) { // @codingStandardsIgnoreStart $ url = @ parse_url ( $ url ) ; // @codingStandardsIgnoreEnd if ( empty ( $ url ) ) { return false ; } $ url = array_map ( 'trim' , $ url ) ; $ url [ 'port' ] = ( ! isset ( $ url [ 'port' ] ) ) ? '' : ( ':' . ( int ) $ url [ 'port' ] ) ; $ path = ( isset ( $ url [ 'path' ] ) ) ? $ url [ 'path' ] : '' ; if ( empty ( $ path ) ) { $ path = '/' ; } $ path .= ( isset ( $ url [ 'query' ] ) ) ? "?$url[query]" : '' ; $ defaults = [ 'http' => [ 'header' => "Accept: text/html\r\n" . "Connection: Close\r\n" . "User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64)\r\n" , ] ] ; stream_context_get_default ( $ defaults ) ; if ( isset ( $ url [ 'host' ] ) && $ url [ 'host' ] !== gethostbyname ( $ url [ 'host' ] ) ) { $ url = "$url[scheme]://$url[host]$url[port]$path" ; $ headers = get_headers ( $ url ) ; if ( is_array ( $ headers ) ) { return $ headers ; } } return false ; }
Parse headers from a specific URL content.

@param string $url
@return mixed array of headers or FALSE on failure
Parse headers from a specific URL content .