php get hostname from url code example
Example 1: php get domain from url
$url = 'http://google.com/dhasjkdas/sadsdds/sdda/sdads.html';
$parse = parse_url($url);
echo $parse['host'];
Example 2: php get url path name
parse_url( $_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH );
Example 3: php get hostname
<?php
echo gethostname();
echo php_uname('n');
?>
Example 4: part of url php
$url = $_SERVER['REQUEST_URI'];
$url_components = parse_url($url);
parse_str($url_components['query'], $params);
$key = $params['key'];
Example 5: php get domain name with https
echo $_SERVER['SERVER_NAME'];