Answers for "php get hostname from url"

PHP
2

php get url path name

parse_url( $_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH );
Posted by: Guest on November-04-2020
5

php get domain from url

$url = 'http://google.com/dhasjkdas/sadsdds/sdda/sdads.html';
$parse = parse_url($url);
echo $parse['host']; // prints 'google.com'
Posted by: Guest on April-29-2020
1

php get hostname

<?php
echo gethostname(); // may output e.g,: sandie

// Or, an option that also works before PHP 5.3
echo php_uname('n'); // may output e.g,: sandie
?>
Posted by: Guest on April-14-2021
-1

php get domain name with https

echo $_SERVER['SERVER_NAME']; //Outputs www.example.com
Posted by: Guest on November-26-2020
0

part of url php

//https://www.google.com/search?key=1234
	$url = $_SERVER['REQUEST_URI']; 
    $url_components = parse_url($url); 
    parse_str($url_components['query'], $params); 
    $key = $params['key']; 

// key=1234
Posted by: Guest on October-06-2020

Browse Popular Code Answers by Language