A simple but complete URL parsers written in PHP
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
CHANGELOG.md
CODEOWNERS
CONTRIBUTING.md
LICENSE.md
README.md
stale.yml

README.md

Build Status Software License Release Github commits (since latest release) GitHub repo size in bytes GitHub contributors

Url Parser

This is a PHP class that provides all of the processing functionality required for manipulating URLs, deconstructing, changing elements and reconstructing.

Provided Methods

  public function reset()
  public function set_url($url = null)
  public function revert_url()
  public function get_original()
  public function get_clean()
  public function get_scheme()
  public function set_scheme($value)
  public function unset_scheme()
  public function get_hostname()
  public function set_hostname($value)
  public function get_port()
  public function set_port($value)
  public function unset_port()
  public function get_username()
  public function set_username($value)
  public function unset_username()
  public function get_password()
  public function set_password($value)
  public function unset_password()
  public function get_path()
  public function set_path($value)
  public function unset_path()
  public function get_query()
  public function set_query($value)
  public function unset_query()
  public function get_fragment()
  public function set_fragment($value)
  public function unset_fragment()
  public function get_domain()
  public function get_query_terms()
  public function set_query_term($key, $value)
  public function unset_query_term($key)
  public function unset_query_terms()
  public function get_search_terms()
  public function unset_search_terms()
  public function rebuild_url()

Demo Usage

include_once '../src/url-parse.php';

$url = "http://www.wolfsoftware.com";

$p = new url_parser();

$p->set_url($url);

echo "Hostname: " . $p->get_hostname() . "\n";
echo "Domain Name: " . $p->get_domain() . "\n";
echo "Scheme: " . $p->get_scheme() . "\n";

The above code yields the following output:

Hostname: www.wolfsoftware.com
Domain Name: wolfsoftware.com
Scheme: http