<?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>
How to get my domain or server url with php?
How to use $_SERVER['SERVER_NAME'] with a href ?
<?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>
PHP $_SERVER['SERVER_NAME'] correct use
<?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>
Subscribe to:
Posts (Atom)