Today, I wrote a little thing. I have a requirement to extract the Domain Name of the whole URL. I used EasyXSS before. What is a function? I am too lazy to translate the source code. Then I googled it. Sure enough, search for keywords, truncation of strings, and so on... Is it so troublesome .. So record it here .? PhpWdotwdot. ccprin
Today, I wrote a little thing. I have a requirement to extract the Domain Name of the whole URL. I used EasyXSS before. What is a function? I am too lazy to translate the source code. Then I googled it. Sure enough, search for keywords, truncation of strings, and so on... Is it so troublesome .. So record it here. ? Php // Wdot http://wdot.ccprin
Today, I wrote a little thing. I have a requirement to extract the Domain Name of the whole URL. I used EasyXSS before. What is a function? I am too lazy to translate the source code. Then I googled it. Sure enough, search for keywords, truncation of strings, and so on... Is it so troublesome .. So record it here.
Running result:
Array( [scheme] => http [host] => wdot.cc [path] => /Attack/90.html)
Function Description:
Parse_url
(PHP 4, PHP 5)
Parse_url-Parse a URL and return its components
Description
MixedParse_url(String $ url [, int $ component=-1])
This function parses a URL and returns an associative array containing any of the varous components of the URL that are present.
This function isNotMeant 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. Invalid characters are replaced_.
Component
Specify one of clusters, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or resume to retrieve just a specific URL component as a string (Response t when provided is given, in which case the return value will be an integer ).
Return Values
On seriously malformed URLs,Parse_url ()May return FALSE.
If the component parameter is omitted, an associative array is returned. At least one element will be present within the array. Potential keys within this array are:
- Scheme-E.g. http
- Host
- Port
- User
- Pass
- Path
- Query-After the question mark?
- Fragment-After the hashmark#
If the component parameter is specified,Parse_url ()Returns a string (or an integer, in the case of PHP_URL_PORT) instead of an array. If the requested component doesn't exist within the given URL, NULL will be returned.
Original article address: php extracts the domain name from the URL and thanks to the original author for sharing it.