search
HomeBackend DevelopmentPHP ProblemHow to remove domain name from url in php

How to remove domain name from url in php

Oct 21, 2020 pm 03:00 PM
phpurldomain name

php method to remove the domain name in the url: first use the parse_url() function to convert the url into an associative array; then remove the domain name. The parse_url() function is used to parse the url and return its components.

How to remove domain name from url in php

The parse_url function converts the URL into an associative array

(Recommended tutorial: php video tutorial)

parse_url parses the URL and returns its components.

Description

parse_url ( string $url [, int $component = -1 ] )

This function parses a URL and returns an associative array containing the various components that appear in the URL.

This function is not used to verify the legitimacy of the given URL. Incomplete URLs are also accepted, and parse_url() will try to parse them as correctly as possible.

Code implementation:

php > $foo = "http://www.example.com/foo/bar?hat=bowler&accessory=cane"; 
php > $blah = parse_url($foo);
php > print_r($blah);
Array(    
    [scheme] => http    
    [host] => www.example.com    
    [path] => /foo/bar    
    [query] => hat=bowler&accessory=cane
)

Related recommendations: php training

The above is the detailed content of How to remove domain name from url in php. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use