Although I've never used this function, based on the documentation it seems that the above code should also include the following:
if ( ! is_array( $url ) ) // Added - Randy
// Parse the original URL
$parse_url = parse_url($url);
// allow parts to be a url Added - Randy
if ( ! is_array( $parts ) )
$parts = parse_url( $parts );
http_build_url
(PECL pecl_http >= 0.21.0)
http_build_url — Bir URL derler
Açıklama
Bir URL derler.
seçenekler değiştirgesine bağlı olarak ikinci URL parçası birinciye katıştırılır.
Değiştirgeler
- url
-
Bir URL, bir dizge biçiminde olabileceği gibi parse_url() işlevinin döndürdüğü şekilde bir ilişkisel dizi de olabilir.
- parçalar
-
Bir URL'nin parçaları, bir dizge biçiminde olabileceği gibi parse_url() işlevinin döndürdüğü şekilde bir ilişkisel dizi de olabilir.
- seçenekler
-
HTTP_URL sabitlerinin bit seviyesinde VEYAlanmış bitmaskı; HTTP_URL_REPLACE öntanımlıdır.
- yeni_url
-
Belirtilirse, parse_url() işlevinin döndürdüğü biçimde oluşturulmuş URL parçaları ile doldurulur.
Dönen Değerler
Başarı durumunda yeni URL bir dizge olarak döndürülür, aksi takdirde FALSE döner.
Örnekler
Örnek 1 - http_build_url() örneği
<?php
echo http_build_url("http://user@gen.tr/pub/index.php?a=b#files",
array(
"scheme" => "ftp",
"host" => "ftp.gen.tr",
"path" => "files/current/",
"query" => "a=c"
),
HTTP_URL_STRIP_AUTH | HTTP_URL_JOIN_PATH | HTTP_URL_JOIN_QUERY | HTTP_URL_STRIP_FRAGMENT
);
?>
Yukarıdaki örneğin çıktısı:
ftp://ftp.gen.tr/pub/files/current/?a=b&a=c
Ayrıca Bakınız
- parse_url() - Bir URL'yi bileşenlerine ayırır
- http_build_str() - Sorgu dizgesi derler
This function has a useful undocumented feature - the defaults are set in such a way that calling it with no parameters returns the full URL of the page being accessed.
If you are looking for a PHP Version of this function, follow the link below:
http://www.mediafire.com/?zjry3tynkg5
Note: I would have added the function here, but I just couldn't get it past the line restrictions without making it impossible to read.
Enjoy.
