php获取浏览者真实IP

php获取浏览者真实IP,代码如下:

<?php 
function getIP(){
	static $realip;
	if (isset($_SERVER)){
		if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
			$realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
		} else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
			$realip = $_SERVER["HTTP_CLIENT_IP"];
		} else {
			$realip = $_SERVER["REMOTE_ADDR"];
		}
	} else {
		if (getenv("HTTP_X_FORWARDED_FOR")){
			$realip = getenv("HTTP_X_FORWARDED_FOR");
		} else if (getenv("HTTP_CLIENT_IP")) {
			$realip = getenv("HTTP_CLIENT_IP");
		} else {
			$realip = getenv("REMOTE_ADDR");
		}
	}
	return $realip;
}
echo getIP();
?>

 

Author: 智宇愚

14 thoughts on “php获取浏览者真实IP

  1. What a data of un-ambiguity and preserveness of valuable knowledge regarding unpredicted feelings.

  2. Hey there! I know this is sort of off-topic however I had to ask.
    Does managing a well-established website such as yours require a lot of work?
    I’m completely new to running a blog however I do write in my journal daily.

    I’d like to start a blog so I will be able to
    share my personal experience and feelings online. Please let me know if you have any recommendations or tips for
    new aspiring blog owners. Appreciate it!

  3. I’m curious to find out what blog platform
    you are using? I’m having some minor security issues with my latest site and I would like to find something more secure.
    Do you have any solutions?

  4. I do trust all of the ideas you’ve presented in your post.
    They’re really convincing and can definitely work.
    Still, the posts are very short for newbies.
    May just you please lengthen them a little from next time?
    Thanks for the post.

  5. Thanks for the marvelous posting! I certainly enjoyed reading
    it, you can be a great author.I will make certain to bookmark your blog
    and definitely will come back someday. I want to encourage you to definitely
    continue your great work, have a nice day!

  6. Attractive section of content. I just stumbled upon your
    web site and in accession capital to assert that
    I acquire actually enjoyed account your blog posts. Any way I will be
    subscribing to your feeds and even I achievement you access consistently
    rapidly.

  7. Have you ever considered creating an e-book or guest authoring on other websites?
    I have a blog based upon on the same information you discuss and would really like to have you share some stories/information. I know
    my audience would appreciate your work. If you
    are even remotely interested, feel free to shoot me
    an email.

  8. php获取浏览者真实IP – 智宇愚
    This is my first time pay a quick visit at here and i am really pleassant to
    read everthing at alone place.

  9. php获取浏览者真实IP – 智宇愚
    I’m gone to tell my little brother, that he should also go to see this webpage on regular
    basis to take updated from latest news.

  10. php获取浏览者真实IP – 智宇愚
    What’s up colleagues, how is all, and what you desire to
    say regarding this post, in my view its actually remarkable in support of me.

  11. I am really loving the theme/designof your web site.
    Do you ever run into any browser compatibility issues?
    A couple of my blog visitors have complained about
    my website not operating correctly in Explorer but looks great
    in Chrome. Do you have any solutions to help fix this problem?

发表评论

电子邮件地址不会被公开。 必填项已用*标注