This article mainly introduces the introduction of the parse_url function in php. It has a certain reference value. Now I share it with you. Friends in need can refer to the
array parse_url(string $url, [$component])
This function parses a URL and returns an associative array containing the various components that appear in the URL
Parameters:
$url, the url parameter to be parsed, replace the invalid string with _
$component, specify PHP_URL_SCHEME
, PHP_URL_HOST
, PHP_URL_PORT
, PHP_URL_USER
, PHP_URL_PASS
, PHP_URL_PATH
, PHP_URL_QUERY or <code>PHP_URL_FRAGMENT
to get the URL. The string of the part specified in . (Except when specified as PHP_URL_PORT
, an integer value will be returned)
Return value
For seriously unqualified URLs, parse_url() may return FALSE
.
If the component
parameter is omitted, an associative array array will be returned, and at least one element will currently be in the array.
The possible keys in the array are as follows
##scheme - such as httphostportuserpasspathquery - after the question mark ? ##fragment - after the hash symbolparameter is specified,#If the
component
parse_url() returns a string
( Or when specified as PHP_URL_PORT
returns an integer
<span class="type">) instead of an </span>array. If the specified component in the URL does not exist,
NULL will be returned.
example
Recommended related articles:
1.Explanation on using php pathinfo(), parse_url(), basename() functions to parse URLsRelated recommendations:
2.Introduction to php using parse_url and parse_str to parse URLs
Related video recommendations:
1.Dugu Jiujian (4)_PHP video tutorial
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
How to abbreviate IF judgment in PHP
##Explanation of string functions in PHP
The above is the detailed content of Introduction to parse_url function in php. For more information, please follow other related articles on the PHP Chinese website!