Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. What's my IP in PHP

What's my IP in PHP

Scheduled Pinned Locked Moved Web Development
phpsysadmintoolstutorial
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joel Holdsworth
    wrote on last edited by
    #1

    Hi, I'm writing a PHP script that runs on my computer, and I was wondering if anyone knows how to retrieve the internet IP of my computer (even if it's behind a router). I tried using gethostbyname('localhost'); and gethostbyname('MYCOMPUTERNAME');, both simply return the IP of the computer within the network. Joel Holdsworth

    A Z 2 Replies Last reply
    0
    • J Joel Holdsworth

      Hi, I'm writing a PHP script that runs on my computer, and I was wondering if anyone knows how to retrieve the internet IP of my computer (even if it's behind a router). I tried using gethostbyname('localhost'); and gethostbyname('MYCOMPUTERNAME');, both simply return the IP of the computer within the network. Joel Holdsworth

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      I'm having the same problem...I used ipconfig though...which works for all computers inside my home's router but nothing appears to work when entered remotely If you figure it out lemme know please... The word of the day is legs, let's go back to my house and spread the word ;P

      1 Reply Last reply
      0
      • J Joel Holdsworth

        Hi, I'm writing a PHP script that runs on my computer, and I was wondering if anyone knows how to retrieve the internet IP of my computer (even if it's behind a router). I tried using gethostbyname('localhost'); and gethostbyname('MYCOMPUTERNAME');, both simply return the IP of the computer within the network. Joel Holdsworth

        Z Offline
        Z Offline
        ZoogieZork
        wrote on last edited by
        #3

        You need to have another server (outside of your network) that you can access to get your external IP (or, as an alternative, a program running on your router that you can query). There are quite a few servers on the web that you can query to get your external IP as seen by the Internet (the first is the easiest to query, but you may want others to fall back on in case the first is down): http://www.phpfreaks.com/myip.php[^] http://www.whatismyip.com/[^] http://www.networkports.net/yourip.php[^] - Mike

        A 1 Reply Last reply
        0
        • Z ZoogieZork

          You need to have another server (outside of your network) that you can access to get your external IP (or, as an alternative, a program running on your router that you can query). There are quite a few servers on the web that you can query to get your external IP as seen by the Internet (the first is the easiest to query, but you may want others to fall back on in case the first is down): http://www.phpfreaks.com/myip.php[^] http://www.whatismyip.com/[^] http://www.networkports.net/yourip.php[^] - Mike

          A Offline
          A Offline
          alex barylski
          wrote on last edited by
          #4

          way cool...thank you :) The word of the day is legs, let's go back to my house and spread the word ;P

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups