In php, the parse_url () function parses the URL and returns the url component. However, note that this function is not used to verify the validity of a given URL, just break it down into the parts listed below. Incomplete URLs are also accepted, and parse_url () tries to parse them correctly as much as possible. This article has collected several articles about parse_url () function URL parsing, hoping to help you understand parse_url () function. In php, the parse_url () function parses the URL and returns the url component. However, note that this function is not used to verify the validity of a given URL, just break it down into the parts listed below. Incomplete URLs are also accepted, and parse_url () tries to parse them correctly as much as possible. This article has collected several articles about parse_url () function URL parsing, hoping to help you understand parse_url () function.
1. explain the definition and usage of the php parse_url () function
In php, the parse_url () function is used to parse the URL and return the url. Its syntax is as follows:
array parse_url(string $url,int component)
The $ url parameter is the URL to be parsed. invalid characters are replaced. $ 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 get the string of the specified part in the URL. (Besides PHP_URL_PORT, an integer value is returned ).
If the $ component parameter is omitted, an associated array is returned.
2. Introduction to parse_url () function usage in php
This article introduces the usage of parse_url () function in php. if you need parse_url () function, refer to this article. In PHP, parse_url is a useful function. parse_url () is used to parse the URL and return the url components. it is particularly convenient for information capture analysis. for example:
3. use parse_url () in php to parse the URL implementation code (parse_url details)
We often send a large string of URLs. if we want to parse the URLs, we can only continue to parse the tokens. However, in php, you must learn to use the functions written by the predecessors, so that the development speed will be faster. Of course, if you want to parse the website, you have to go to the relevant instructions. what you want to introduce today is the parse_url function in php. This function is mainly used to parse the website address. First, let's take a look at this function prototype. its official description is as follows:
4. use the php pathinfo (), parse_url (), basename () function to parse the URL instance.
PHP functions pathinfo (), parse_url (), and basename () are all URL-resolved functions, but there are also some differences. This article lists some examples, we hope that these instances will help you better understand the usage methods and skills of these three functions. let's take a look:The pathinfo function is used to obtain the path, directory, or file name of a file. The parse_url () function is used to parse the URL and return an Associated array of the resolution components. This function does not check whether the URL is legal, but only resolves the URL correctly. Name of the file in the returned path of the basename () function
[Recommended related articles]
The difference between parse_str () function and parse_url () function parsing URL
PHP simulates the second POST request and uses PHP and JS to process URL information.
The above is a summary of the URL usage of php parse_url () function parsing. For more information, see other related articles in the first PHP community!