PHP: parse_url - Manual in Deutsh
PHP: parse_url - Manual in French
PHP: parse_url - Manual in Polish

You Are At PHP: parse_url - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

parse_url

(PHP 3, PHP 4, PHP 5)

parse_url -- Parse a URL and return its components

Description

mixed parse_url ( string url [, int component] )

This function parses a URL and returns an associative array containing any of the various components of the URL that are present.

This function is not meant to validate the given URL, it only breaks it up into the above listed parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly.

Parameters

url

The URL to parse

component

Specify one of PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT to retrieve just a specific URL component as a string.

Return Values

On seriously malformed URLs, parse_url() may return FALSE and emit a E_WARNING. Otherwise an associative array is returned, whose components may be (at least one):

If the component parameter is specified a string is returned instead of an array.

ChangeLog

VersionDescription
5.1.2Added the component parameter

Examples

Example 1. A parse_url() example

<?php
$url
= 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

echo
parse_url($url, PHP_URL_PATH);
?>

The above example will output:

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)
/path

Notes

Note: This function doesn't work with relative URLs.

Note: This function is intended specifically for the purpose of parsing URLs and not URIs. However, to comply with PHP's backwards compatibility requirements it makes an exception for the file:// scheme where tripple slashes (file:///...) are allowed. For any other scheme this is invalid.

See Also

pathinfo()
parse_str()
http_build_query()
dirname()
basename()

Najlepsza ochrona mienia na rynku
tłumaczenia
opakowania z nadrukiem
Najlepsza organizacja eventów Gorąco Polecamy!
Strony internetowe

Another Useful functions:


zend-api.zend-parse-parameters | zend-api.zend-parse-parameters-ex | zend-api.zend-parse-method-parameters | zend-api.zend-parse-method-parameters-ex | zend-api.zend-parse-ini-file | ref.parsekit | ref.mailparse | migration4.parser | function.yaz-ccl-parse | function.xmlrpc-server-add-introspection-data | function.xmlrpc-parse-method-descriptions | function.xmlrpc-parse-method-descriptions | function.xmlrpc-is-fault | function.xmlreader-setparserproperty | function.xmlreader-getparserproperty | function.xml-set-unparsed-entity-decl-handler | function.xml-parser-set-option | function.xml-parser-get-option | function.xml-parser-free | function.xml-parser-create | function.xml-parser-create-ns | function.xml-parse | function.xml-parse-into-struct | function.tidy-parse-string | function.tidy-parse-file | function.swishresults-getparsedwords | function.parsekit-func-arginfo | function.parsekit-compile-string | function.parsekit-compile-file | function.parse-url | function.parse-str | function.parse-ini-file | function.ora-parse | function.openssl-x509-parse | function.ociparse | function.oci-parse | function.mysqli-rpl-parse-enabled | function.mysqli-enable-rpl-parse | function.mysqli-disable-rpl-parse | function.mb-parse-str | function.maxdb-rpl-parse-enabled | function.maxdb-enable-rpl-parse | function.maxdb-disable-rpl-parse | function.mailparse-uudecode-all | function.mailparse-stream-encode | function.mailparse-rfc822-parse-addresses | function.mailparse-msg-parse | function.mailparse-msg-parse-file | function.mailparse-msg-get-structure | function.mailparse-msg-get-part | function.mailparse-msg-get-part-data | function.mailparse-msg-free | function.mailparse-msg-extract-whole-part-file | function.mailparse-msg-extract-part | function.mailparse-msg-extract-part-file | function.mailparse-msg-create | function.mailparse-determine-best-xfer-encoding | function.m-parsecommadelimited | function.ldap-parse-result | function.ldap-parse-reference | function.iptcparse | function.imap-rfc822-parse-headers | function.imap-rfc822-parse-adrlist | function.http-parse-params | function.http-parse-message | function.http-parse-headers | function.http-parse-cookie | function.gopher-parsedir | function.date-parse | function.bcompiler-parse-class |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.