by prettyscripts on 2007-12-17 01:15:42
PHP:
"http" . ($_SERVER['HTTPS']) ? "s" : "") . "://" . | |
$_SERVER['SERVER_NAME'] . | |
((in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? "" : ":" . $_SERVER['SERVER_PORT']) . | |
"/" |
$_SERVER[’HTTPS’] will be non-empty value if it’s running over ssl or using https protocol.
$_SERVER[’SERVER_PORT’] 80 is standard port and 443 is standard ssl port. the port number will be appended to the url if not using these 2 standard ports.