Re: IP address enconding
| From: | Knut H. Hassel Nielsen | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: IP address enconding | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49344@lists.php.net to get a copy of this message | ||
On Thu, 19 Apr 2001, elias wrote:
> Hello.
>
> How can i get the IP address of the user who's browsing my current script?
> how can i do it via JavaScript and PHP please.
$REMOTE_ADDR should do the trick (use 'phpinfo()' to see for yourself)
> And if i got an IP address such 192.168.0.2
> i believe it will be returned as a string....Is there is a function to
> encode it to an Integer and the decode it back to a string? or i have to
> code it myself?
>
> -elias
It is a string, so you couldn't make an integer out of it anymore than making
any other string into an integer. The '.' isn't a legal digit.
You'll have to split it up into different blocks (use split)
--
Knut
------
Knut H. Hassel Nielsen
Principal Engineer / Avdelingsingeniør
Norwegian University of Science and Technology / NTNU
Department of Computer and Information Science / IDI
N-7491 Trondheim, Norway
Phone Office / Telefon jobb : (+47) 73 59 18 46
Fax Office / Telefax jobb : (+47) 73 59 17 33
Cell. Phone / Mobiltelefon : 91 59 86 06