How to get my domain or server url with php?

<?php
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')=== FALSE ? 'http' : 'https';
$host = $_SERVER['HTTP_HOST'];
$website = $protocol . '://' . $host;
?>

<a href="<?php echo $website; ?>">my site</a>

No comments:

Post a Comment