Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Client Machine Name in PHP

Tags:

This program only returns the client machine name in localhost only

echo gethostbyaddr($_SERVER['REMOTE_ADDR']);

If it is run from an online server, then computer name is not shown and some other information is being shown. So is there anyway to get the computer name in php when the program runs from online server.

like image 214
Deepak Avatar asked Feb 28 '11 12:02

Deepak


People also ask

How to get device name in PHP?

Use the superglobal $_SERVER . Most important for your purpous I guess would be $info->platform . It will be very unlikely to retrieve a SPECIFIC device name from this.


2 Answers

What's this "other information"? An IP address?

In PHP, you use $_SERVER['REMOTE_ADDR'] to get the IP address of the remote client, then you can use gethostbyaddr() to try and conver that IP into a hostname - but not all IPs have a reverse mapping configured.

like image 94
Marc B Avatar answered Sep 16 '22 16:09

Marc B


Not in PHP.
phpinfo(32) contains everything PHP able to know about particular client, and there is no [windows] computer name

like image 22
Your Common Sense Avatar answered Sep 18 '22 16:09

Your Common Sense