KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm working on a website, and one of the things I would like to do is display MY IP address to users. The website is made with CodeIgniter, so I was looking to find my server IP with PHP. The IP address may change (it's a roamer), so I'd like to find it dynamically, not just hard code it. I tried this: $data['hostname'] = NULL; $data['ip'] = NULL; $var = gethostname(); if ($var === FALSE) { $var = NULL; } else { $data['hostname'] = $var; $data['ip'] = gethostbyname($var); } However, instead of giving me the Hostname and the IP, I got: "Moria" and "127.0.1.1". Not quite what I am looking for. Rather, it should say "Moria.student.rit.edu" for the Hostname, and the IP address. Any help?
Tags (comma-separated)
Save Edits
Cancel