php 判断当前url是http还是https的方法,代码如下:

<?php $slhttp = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
 (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; 
echo $slhttp;
?>