PHP Get Hostname?

wpspeedster

Well-known member
Registered
Joined
May 6, 2016
Messages
120
Points
18
I have a small php application that is installed on websites and on different VPS hostings. I need a fast and reliable way to get the server's hostname that using PHP code to get or some other unique and reliable system identifier. Can you tell me what is the best way to get hostname with PHP? I can check hostname by using these guides from this post https://forumweb.hosting/13227-how-to-change-hostname-for-my-vps.html but I don't know how to deal that with PHP language.
 

NickR

Active member
Registered
Joined
Jan 14, 2017
Messages
84
Points
8
Use gethostname()

Just echo the output or store it in a variable.

Code:
$hostname = gethostname();
 

WhiteVM

Member
Registered
Joined
Dec 6, 2016
Messages
18
Points
3
Simple and easy, also you have a lot of functions on PHP website, Visit them :)
Code:
<?php
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
?>
 
Latest Threads
Replies
0
Views
40
Replies
0
Views
48
Replies
1
Views
49
Replies
0
Views
243
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top