当前url:http://localhost:805/test/helloworld.php
1
2
3
4
5
6
7
|
echo ‘SERVER_NAME:‘ . $_SERVER [ ‘SERVER_NAME‘ ]; //获取当前域名(不含端口号)
echo ‘<p>‘ ;
echo ‘HTTP_HOST:‘ . $_SERVER [ ‘HTTP_HOST‘ ]; //获取当前域名 (含端口号)
echo ‘<p>‘ ;
echo ‘REQUEST_URI:‘ . $_SERVER [ ‘REQUEST_URI‘ ]; //获取当前域名的后缀
|
效果: