1. Home
  2. Php
  3. Parse url
#php

Lets you parse a URL and retrieve parts like scheme, hostname, port, path, query, fragment, username, and password.

$url_to_parse = "https://shortcode.dev/php-cheatsheet?var=hello#php-cheatsheet";
$parsed = parse_url($url_to_parse);

echo $parsed['scheme'];     // https
echo $parsed['hostname'];   // shortcode.dev
echo $parsed['port'];       // ie. 8080
echo $parsed['path'];       // /php-cheatsheet
echo $parsed['query'];      // var=hello
echo $parsed['fragment'];   // php-cheatsheet
copy
Full Php cheatsheet
Sitemap Git repository