How to get value of my dynamic ip?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kabuki1985
Forum Commoner
Posts: 32
Joined: Thu Jun 15, 2006 10:19 pm

How to get value of my dynamic ip?

Post by kabuki1985 »

Hi,
I want to test a tcp server using PHP. Is there a way to get the value of my ip without hardcoding it? So that i can test it from another computer without changing the ip everytime my server ip changes ?
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post by Flamie »

User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Put this online somewhere like http://www.mydomain.com/myscript.php:

Code: Select all

<?php echo $_SERVER['REMOTE_ADDR']; ?>
Then, in your script:

Code: Select all

<?php $myIP = file_get_contents("http://www.mydomain.com/myscript.php"); ?>
I think that would work. I've not tested it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_SERVER['SERVER_ADDR'] I think may be what the original poster is actually looking for.
Post Reply