面试题目: 获取服务器IP和客户端IP
[面试题目] 怎么获取服务器IP和客户端IP地址?
I. PHP获取客户端IP, 可通过下面系统变量
1. $_SERVER['Remote_Addr']
2. $_SERVER['HTTP_CLIENT_IP']
3. $_SERVER['HTTP_X_FORWARDED_FOR']
II. PHP获取服务端IP ,主要通过这个系统函数(gethostbyname),把服务器域名传进去就OK
1. $_SERVER['SERVER_ADDR']
2. gethostbyname($_SERVER['SERVER_NAME'])
注:也可以通过getenv来获取 比如:getevn('Remote_Addr')
===================== This is my sign! =======================================================
The moment you want to give up, thing about why did insist to come here !