Phpparse_url () function parsing URL usage summary

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.