How to Get Hostname Using PHP?

Definition and Usage

The gethostname() function returns the host name for the local machine.

Syntax:-

gethostname()

Hello friends, today I will tell you through experts php tutorial how you can get server hostname Using php. So let’s try to understand step to step with example.

<?php
echo gethostname();
?>