Introduction to parse_url function in php

不言
Release: 2023-04-02 22:56:02
Original
15652 people have browsed it

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

parse_url() function—— Parse the URL and return its components

array parse_url(string $url, [$component])
Copy after login

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 http

host

port

user

pass

path

query - after the question mark ? ##fragment - after the hash symbol

#If the

component
parameter is specified,

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 URLs
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!
Related recommendations:

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template