Requests_Transport_fsockopen::format_get()

最后更新于:2021-11-26 04:08:00

Requests_Transport_fsockopen::format_get( array$url_parts, array|object$data)

Format a URL given GET data

参数

$url_parts

(array) (Required)

$data

(array|object) (Required) Data to build query using, see https://secure.php.net/http_build_query

响应

(string) URL with data

源文件

文件: gc-includes/Requests/Transport/fsockopen.php

	protected static function format_get($url_parts, $data) {
		if (!empty($data)) {
			if (empty($url_parts['query'])) {
				$url_parts['query'] = '';
			}

			$url_parts['query'] .= '&' . http_build_query($data, '', '&');
			$url_parts['query']  = trim($url_parts['query'], '&');
		}
		if (isset($url_parts['path'])) {
			if (isset($url_parts['query'])) {
				$get = $url_parts['path'] . '?' . $url_parts['query'];
			}
			else {
				$get = $url_parts['path'];
			}
		}
		else {
			$get = '/';
		}
		return $get;
	}