Sunday 18 August 2019

Get Client Machine Name in PHP

This snippet will help you to get the name of your pc


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

echo gethostname(); // may output e.g,: sandie

// Or, an option that also works before PHP 5.3
echo php_uname('n'); // may output e.g,: sandie

This work locally not server

Server Error Note:
PHP Notice:  Undefined index: REMOTE_ADDR in /home/UMAQ6W/prog.php on line 4
PHP Warning:  gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/UMAQ6W/prog.php on line 4
Previous Post
Next Post

post written by:

0 Comments:

Hit me with a comment!