GC_HTTP_IXR_Client::__construct()

最后更新于:2021-12-01 11:12:32

GC_( string$server, string|false$path=false, int|false$port=false, int$timeout=15)

参数

$server

(string) (Required)

$path

(string|false) (Optional)

Default value: false

$port

(int|false) (Optional)

Default value: false

$timeout

(int) (Optional)

Default value: 15

源文件

文件: gc-includes/class-gc-http-ixr-client.php

	public function __construct( $server, $path = false, $port = false, $timeout = 15 ) {
		if ( ! $path ) {
			// Assume we have been given a URL instead.
			$bits         = parse_url( $server );
			$this->scheme = $bits['scheme'];
			$this->server = $bits['host'];
			$this->port   = isset( $bits['port'] ) ? $bits['port'] : $port;
			$this->path   = ! empty( $bits['path'] ) ? $bits['path'] : '/';

			// Make absolutely sure we have a path.
			if ( ! $this->path ) {
				$this->path = '/';
			}

			if ( ! empty( $bits['query'] ) ) {
				$this->path .= '?' . $bits['query'];
			}
		} else {
			$this->scheme = 'http';
			$this->server = $server;
			$this->path   = $path;
			$this->port   = $port;
		}
		$this->useragent = 'The Incutio XML-RPC PHP Library';
		$this->timeout   = $timeout;
	}