php 判断https,PHP 判断当前地址是 HTTP 还是 HTTPS

$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';

$url = $http_type . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

echo $url;

另:打印 $_SERVER

2e514c798cfd36966118804aa1c41f91.png

array(75) {

["ALLUSERSPROFILE"] => string(14) "C:\ProgramData"

["APPDATA"] => string(30) "C:\Users\imfon\AppData\Roaming"

["asl_log"] => string(16) "Destination=file"

["CommonProgramFiles"] => string(35) "C:\Program Files (x86)\Common Files"

["CommonProgramFiles(x86)"] => string(35) "C:\Program Files (x86)\Common Files"

["CommonProgramW6432"] => string(29) "C:\Program Files\Common Files"

["COMPUTERNAME"] => string(15) "DESKTOP-439RV67"

["ComSpec"] => string(27) "C:\Windows\system32\cmd.exe"

["FPS_BROWSER_APP_PROFILE_STRING"] => string(17) "Internet Explorer"

["FPS_BROWSER_USER_PROFILE_STRING"] => string(7) "Default"

["HOMEDRIVE"] => string(2) "C:"

["HOMEPATH"] => string(12) "\Users\imfon"

["LOCALAPPDATA"] => string(28) "C:\Users\imfon\AppData\Local"

["LOGONSERVER"] => string(17) "\\DESKTOP-439RV67"

["NUMBER_OF_PROCESSORS"] => string(1) "4"

["OneDrive"] => string(23) "C:\Users\imfon\OneDrive"

["OS"] => string(10) "Windows_NT"

["Path"] => string(640) "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Common Files\Thunder Network\KanKan\Codecs;C:\ProgramData\ComposerSetup\bin;C:\phpStudy2018\PHPTutorial\php\php-7.2.1-nts;C:\phpStudy2018\PHPTutorial\php\php-5.6.27-nts;C:\Users\imfon\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\imfon\AppData\Local\Programs\Python\Python36-32\;C:\Users\imfon\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Sublime Text 3;C:\Program Files\Bandizip\;C:\Users\imfon\AppData\Roaming\Composer\vendor\bin"

["PATHEXT"] => string(53) ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"

["PROCESSOR_ARCHITECTURE"] => string(3) "x86"

["PROCESSOR_ARCHITEW6432"] => string(5) "AMD64"

["PROCESSOR_IDENTIFIER"] => string(50) "Intel64 Family 6 Model 78 Stepping 3, GenuineIntel"

["PROCESSOR_LEVEL"] => string(1) "6"

["PROCESSOR_REVISION"] => string(4) "4e03"

["ProgramData"] => string(14) "C:\ProgramData"

["ProgramFiles"] => string(22) "C:\Program Files (x86)"

["ProgramFiles(x86)"] => string(22) "C:\Program Files (x86)"

["ProgramW6432"] => string(16) "C:\Program Files"

["PROMPT"] => string(4) "$P$G"

["PSModulePath"] => string(93) "C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules"

["PUBLIC"] => string(15) "C:\Users\Public"

["SystemDrive"] => string(2) "C:"

["SystemRoot"] => string(10) "C:\Windows"

["TEMP"] => string(33) "C:\Users\imfon\AppData\Local\Temp"

["TMP"] => string(33) "C:\Users\imfon\AppData\Local\Temp"

["USERDOMAIN"] => string(15) "DESKTOP-439RV67"

["USERDOMAIN_ROAMINGPROFILE"] => string(15) "DESKTOP-439RV67"

["USERNAME"] => string(5) "imfon"

["USERPROFILE"] => string(14) "C:\Users\imfon"

["VBOX_MSI_INSTALL_PATH"] => string(35) "C:\Program Files\Oracle\VirtualBox\"

["WEBKIT_IGNORE_SSL_ERRORS"] => string(1) "1"

["windir"] => string(10) "C:\Windows"

["HTTP_CACHE_CONTROL"] => string(9) "max-age=0"

["HTTP_UPGRADE_INSECURE_REQUESTS"] => string(1) "1"

["HTTP_CONNECTION"] => string(10) "keep-alive"

["HTTP_COOKIE"] => string(36) "PHPSESSID=8vko98pn93mnds928cckusf990"

["HTTP_ACCEPT_ENCODING"] => string(13) "gzip, deflate"

["HTTP_ACCEPT_LANGUAGE"] => string(59) "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"

["HTTP_ACCEPT"] => string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"

["HTTP_USER_AGENT"] => string(78) "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0"

["HTTP_HOST"] => string(11) "www.ald.com"

["REDIRECT_STATUS"] => string(3) "200"

["SERVER_NAME"] => string(11) "www.ald.com"

["SERVER_PORT"] => string(2) "80"

["SERVER_ADDR"] => string(9) "127.0.0.1"

["REMOTE_PORT"] => string(5) "13790"

["REMOTE_ADDR"] => string(9) "127.0.0.1"

["SERVER_SOFTWARE"] => string(12) "nginx/1.11.5"

["GATEWAY_INTERFACE"] => string(7) "CGI/1.1"

["SERVER_PROTOCOL"] => string(8) "HTTP/1.1"

["DOCUMENT_ROOT"] => string(30) "C:/wwwroot/www.1001alading.com"

["DOCUMENT_URI"] => string(10) "/index.php"

["REQUEST_URI"] => string(13) "/api/news/www"

["SCRIPT_NAME"] => string(10) "/index.php"

["CONTENT_LENGTH"] => string(0) ""

["CONTENT_TYPE"] => string(0) ""

["REQUEST_METHOD"] => string(3) "GET"

["QUERY_STRING"] => string(14) "s=api/news/www"

["PATH_TRANSLATED"] => string(30) "C:/wwwroot/www.1001alading.com"

["PATH_INFO"] => string(8) "news/www"

["SCRIPT_FILENAME"] => string(40) "C:/wwwroot/www.1001alading.com/index.php"

["FCGI_ROLE"] => string(9) "RESPONDER"

["PHP_SELF"] => string(10) "/index.php"

["REQUEST_TIME_FLOAT"] => float(1523264712.1606)

["REQUEST_TIME"] => int(1523264712)

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值