Requests_Transport_fsockopen::format_get() WordPress Method

The format_get() method of the Requests_Transport_fsockopen class formats a GET request for use with the fsockopen() function. This function takes a URL and an array of parameters, and returns a string containing the formatted request.

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

Format a URL given GET data


Parameters

$url_parts

(array)(Required)

$data

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


Top ↑

Return

(string) URL with data


Top ↑

Source

File: wp-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;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.