📜  在 php 代码示例中获取带有协议的站点 url

📅  最后修改于: 2022-03-11 14:54:40.982000             🧑  作者: Mango

代码示例1
function siteURL() {
  $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || 
    $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
  $domainName = $_SERVER['HTTP_HOST'];
  return $protocol.$domainName;
}