{"id":694,"date":"2012-02-22T07:20:06","date_gmt":"2012-02-22T07:20:06","guid":{"rendered":"http:\/\/www.vishmax.com\/en\/?p=694"},"modified":"2012-05-19T12:29:17","modified_gmt":"2012-05-19T12:29:17","slug":"php-code-for-getting-ip-address-of-visitors","status":"publish","type":"post","link":"https:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/","title":{"rendered":"How to get client&#8217;s IP address in PHP"},"content":{"rendered":"<p>Some times you need to track the visitors IP address for a particular reason. Here is some PHP codes which is usfun for those projects which needs to track IP address.<\/p>\n<h2>What is your IP Address<\/h2>\n<pre lang=\"php\">\r\n<?php\r\n$ipaddress=@$REMOTE_ADDR; \r\necho \"Your IP Address is : = $ipaddress\";\r\n?>\r\n<\/pre>\n<p>The above code will display your IP address.<\/p>\n<h2>Function<\/h2>\n<pre lang=\"php\">\r\n<?php\r\n\/\/Return the visitor's IP address\r\nfunction get_ip(){\r\n if (isset($_SERVER[\"REMOTE_ADDR\"]))\r\n { \r\n $ip=$_SERVER[\"REMOTE_ADDR\"] . ' '; \r\n } else if ( isset($_SERVER[\"HTTP_X_FORWARDED_FOR\"]) ) { \r\n $ip=$_SERVER[\"HTTP_X_FORWARDED_FOR\"] . ' '; \r\n } else if ( isset($_SERVER[\"HTTP_CLIENT_IP\"]) ) { \r\n $ip=$_SERVER[\"HTTP_CLIENT_IP\"] . ' '; \r\n }\r\n return $ip;\r\n}\r\n?>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Some times you need to track the visitors IP address for a particular reason. Here is some PHP codes which is usfun for those projects which needs to track IP address. What is your IP Address The above code will display your IP address. Function<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[44],"tags":[72,48],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to get client&#039;s IP address in PHP - Vishmax.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get client&#039;s IP address in PHP - Vishmax.com\" \/>\n<meta property=\"og:description\" content=\"Some times you need to track the visitors IP address for a particular reason. Here is some PHP codes which is usfun for those projects which needs to track IP address. What is your IP Address The above code will display your IP address. Function\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\" \/>\n<meta property=\"og:site_name\" content=\"Vishmax.com\" \/>\n<meta property=\"article:published_time\" content=\"2012-02-22T07:20:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-05-19T12:29:17+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93\"},\"headline\":\"How to get client&#8217;s IP address in PHP\",\"datePublished\":\"2012-02-22T07:20:06+00:00\",\"dateModified\":\"2012-05-19T12:29:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\"},\"wordCount\":54,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#organization\"},\"keywords\":[\"Code Library\",\"PHP\"],\"articleSection\":[\"Labs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\",\"url\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\",\"name\":\"How to get client's IP address in PHP - Vishmax.com\",\"isPartOf\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#website\"},\"datePublished\":\"2012-02-22T07:20:06+00:00\",\"dateModified\":\"2012-05-19T12:29:17+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.vishmax.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get client&#8217;s IP address in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#website\",\"url\":\"http:\/\/www.vishmax.com\/en\/\",\"name\":\"Vishmax.com\",\"description\":\"Software Company in Calicut for Web Design and eCommerce\",\"publisher\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.vishmax.com\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#organization\",\"name\":\"Vishmax.com\",\"url\":\"http:\/\/www.vishmax.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png\",\"contentUrl\":\"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png\",\"width\":150,\"height\":50,\"caption\":\"Vishmax.com\"},\"image\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g\",\"caption\":\"admin\"},\"url\":\"https:\/\/www.vishmax.com\/en\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to get client's IP address in PHP - Vishmax.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/","og_locale":"en_US","og_type":"article","og_title":"How to get client's IP address in PHP - Vishmax.com","og_description":"Some times you need to track the visitors IP address for a particular reason. Here is some PHP codes which is usfun for those projects which needs to track IP address. What is your IP Address The above code will display your IP address. Function","og_url":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/","og_site_name":"Vishmax.com","article_published_time":"2012-02-22T07:20:06+00:00","article_modified_time":"2012-05-19T12:29:17+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#article","isPartOf":{"@id":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/"},"author":{"name":"admin","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93"},"headline":"How to get client&#8217;s IP address in PHP","datePublished":"2012-02-22T07:20:06+00:00","dateModified":"2012-05-19T12:29:17+00:00","mainEntityOfPage":{"@id":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/"},"wordCount":54,"commentCount":0,"publisher":{"@id":"http:\/\/www.vishmax.com\/en\/#organization"},"keywords":["Code Library","PHP"],"articleSection":["Labs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/","url":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/","name":"How to get client's IP address in PHP - Vishmax.com","isPartOf":{"@id":"http:\/\/www.vishmax.com\/en\/#website"},"datePublished":"2012-02-22T07:20:06+00:00","dateModified":"2012-05-19T12:29:17+00:00","breadcrumb":{"@id":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.vishmax.com\/en\/labs\/php-code-for-getting-ip-address-of-visitors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.vishmax.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to get client&#8217;s IP address in PHP"}]},{"@type":"WebSite","@id":"http:\/\/www.vishmax.com\/en\/#website","url":"http:\/\/www.vishmax.com\/en\/","name":"Vishmax.com","description":"Software Company in Calicut for Web Design and eCommerce","publisher":{"@id":"http:\/\/www.vishmax.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.vishmax.com\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/www.vishmax.com\/en\/#organization","name":"Vishmax.com","url":"http:\/\/www.vishmax.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png","contentUrl":"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png","width":150,"height":50,"caption":"Vishmax.com"},"image":{"@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g","caption":"admin"},"url":"https:\/\/www.vishmax.com\/en\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts\/694"}],"collection":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/comments?post=694"}],"version-history":[{"count":0,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts\/694\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/media?parent=694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/categories?post=694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/tags?post=694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}