Build a URL. The parts of the second URL will be merged into the first according to the flags argument.
public static buildAll ( mixed $url, mixed $parts = [], integer $flags = self::URL_REPLACE, array &$newUrl = [] ) : string | ||
$url | mixed | (part(s) of) an URL in form of a string or associative array like parse_url() returns |
$parts | mixed | same as the first argument |
$flags | integer | a bitmask of binary or'ed HTTP_URL constants; HTTP_URL_REPLACE is the default |
$newUrl | array | if set, it will be filled with the parts of the composed url like parse_url() would return |
리턴 | string |
public function testHttpBuildUrl() { $url = 'http://*****:*****@example.com:8080/path/?query#fragment'; $expected = 'http://example.com/'; $actual = Url::buildAll($url, array(), Url::URL_STRIP_ALL); is($expected, $actual); $expected = 'http://example.com:8080/path/?query#fragment'; $actual = Url::buildAll($url, array(), Url::URL_STRIP_AUTH); is($expected, $actual); is('https://dev.example.com/', Url::buildAll('http://example.com/', array('scheme' => 'https', 'host' => 'dev.example.com'))); is('http://example.com/#hi', Url::buildAll('http://example.com/', array('fragment' => 'hi'), Url::URL_REPLACE)); is('http://example.com/page', Url::buildAll('http://example.com/', array('path' => 'page'), Url::URL_JOIN_PATH)); is('http://example.com/page', Url::buildAll('http://example.com', array('path' => 'page'), Url::URL_JOIN_PATH)); is('http://example.com/?hi=Bro', Url::buildAll('http://example.com/', array('query' => 'hi=Bro'), Url::URL_JOIN_QUERY)); is('http://example.com/?show=1&hi=Bro', Url::buildAll('http://example.com/?show=1', array('query' => 'hi=Bro'), Url::URL_JOIN_QUERY)); is('http://admin@example.com/', Url::buildAll('http://example.com/', array('user' => 'admin'))); is('http://*****:*****@example.com/', Url::buildAll('http://example.com/', array('user' => 'admin', 'pass' => '1'))); }