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.
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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
Chinese version, very easy to use
