PHP determines whether http or https, and how to get the current url

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

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324413612&siteId=291194637