Page 1 of 1

How to get value of my dynamic ip?

Posted: Wed Dec 20, 2006 3:39 am
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 ?

Posted: Wed Dec 20, 2006 4:02 am
by Flamie

Posted: Wed Dec 20, 2006 4:18 am
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.

Posted: Tue Dec 26, 2006 8:24 am
by feyd
$_SERVER['SERVER_ADDR'] I think may be what the original poster is actually looking for.