Skip to content

Instantly share code, notes, and snippets.

@zhanglianxin
Created November 28, 2021 11:23
Show Gist options
  • Save zhanglianxin/f3177bc80e5497a25c46fc3586ca918c to your computer and use it in GitHub Desktop.
Save zhanglianxin/f3177bc80e5497a25c46fc3586ca918c to your computer and use it in GitHub Desktop.
<?php
function is_secure() {
return (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && in_array(strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']), ['https', 'on', 'ssl', '1'], true)) ||
(isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) || false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment