Home >Backend Development >PHP Tutorial >How to get each part of php URL (global variables)
Output: Array ( [scheme] => http [host] => www.electrictoolbox.com [path] => /php-extract-domain-from-full-url/ ) Example 2:
output: Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value [fragment] => anchor ) It is easy to decompose the various parts of a URL, and it is also easy to extract the specified parts: echo parse_url($url, PHP_URL_PATH); In the second parameter, set the following parameters: 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. |