• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Show visitor ip address php code

August 10, 2013 by Sharad Chhetri Leave a Comment

In this post we will learn how to use php to get the visitor’s IP address in a webpage.
This code also helps Network or system admin to know from which IP he is using currently.

For eg. your company have 2 public IP from different ISP and both are in failover. The companies network is NAT with single public IP. Means if one ISP internet goes down ,it will failover to second ISP internet connection.
You do not have access of network devices. Suddenly the internet disconnected for a few seconds,now through website you have to determine which ISP network is running.

For this purpose sometimes we use some website like whatismyip.org which is famous one. Instead of using these website you can create your own. Now it is up to you ,how far you can use this method.

The below given php code will help you to show the visitor’s IP address in Dashbaord.
$_SERVER['REMOTE_ADDR'];

Create a file with .php extension and paste the given below code

<?php
echo "Your IP Address:"; 
echo $_SERVER['REMOTE_ADDR']; 
?>

Demo: myip.sharadchhetri.com

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to hide php version information in header
  2. php 5.5 APC : ERROR: `make’ failed
  3. PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0
  4. Install php 5.4 on CentOS 6 with yum command
  5. linux release renew dhcp assigned ip address
  6. Show running process in postgresql
  7. Do not show line haveing particular keyword by grep command
  8. grep command to show lines after and before the keyword
  9. show post excerpt in atoms feed of octopress
  10. How to show line numbers with less command in Linux

Filed Under: Linux, Tips And Tricks Tagged With: php

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Run the script using nohup without hitting enter key two times

Allow wget and yum in iptable

GNU Screen

convert space into new line using sed command

How to reset forgot root password in CentOS 6.x and Redhat 6.x

How to empty Trash through command line in Ubuntu

Convert hyphen to underscore in between all filenames shell script

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy