Hi,
Does anyone know how I can get the name of a computer using PHP.
Thanks,
Darren
Hi,
Does anyone know how I can get the name of a computer using PHP.
Thanks,
Darren
Darren Darkins
If you're after the name of the host the PHP script is running on you can use $_SERVER['SERVER_NAME'];
If you're after the name of a computer that's connected to the script you can get it's IP from $_SERVER['REMOTE_ADDR'] and gethostbyaddr.
Will return the name of the local host.Code:echo gethostbyaddr('127.0.0.1');
If none of those are what you are after then let me know and I'll try again.
Hi speed,
thanks for that - I'm probably not making it clear what I need as a lot of people on other forums have offered the same solution.
I'm looking to get the actual name that the user gives the computer, which might be a windows only thing? For example, I have a laptop I call D-LAPTOP.
Hope that makes a bit more sense - it's a bit of a long shot anyway as I guess it isn't the sort of information you should be able to just access.
THanks for your help
Darren Darkins
Ok, I don't use PHP on Windows nor do I have it installed to test this but have you tried reading the environment variable COMPUTERNAME?
getenv('HOSTNAME') should return the host name on Linux.