一、PHP获取域名地址
$host = $_SERVER['HTTP_HOST'];
二、PHP获取域名后面的所有字符
$host = $_SERVER['REQUEST_URI'];
//https://www.baidu.com/md/?articleId=134157878
//输出 /md/?articleId=134157878
三、PHP获取服务器的IP
$serverIP = $_SERVER['SERVER_ADDR'];
echo "服务器IP地址是:" . $serverIP;
//服务器IP地址是:103.40.21.106
四、PHP获取http请求还是https请求文章来源:https://www.toymoban.com/news/detail-741720.html
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
五、PHP获取本站网址 https://www.baidu.com文章来源地址https://www.toymoban.com/news/detail-741720.html
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
$host = $_SERVER['HTTP_HOST'];
$base=$http_type.$host;
到了这里,关于PHP获取域名地址的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!