Requests_Transport_cURL::format_get( string $url, array|object $data )

Format a URL given GET data


Description Description


Parameters Parameters

$url

(string) (Required)

$data

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


Top ↑

Return Return

(string) URL with data


Top ↑

Source Source

File: wp-includes/Requests/Transport/cURL.php

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

			$query .= '&' . http_build_query($data, null, '&');
			$query = trim($query, '&');

			if (empty($url_parts['query'])) {
				$url .= '?' . $query;
			}
			else {
				$url = str_replace($url_parts['query'], $query, $url);
			}
		}
		return $url;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.