第一种:
((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://':'http://';
第二种:
(int)$_SERVER['SERVER_PORT'] == 80 ? 'http' : 'https';
第一种:
((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://':'http://';
第二种:
(int)$_SERVER['SERVER_PORT'] == 80 ? 'http' : 'https';
转载于:https://my.oschina.net/u/2364788/blog/3077324