PHP Function Reference

PHP gethostname() Function



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

Syntax

gethostname()

Parameters

No parameter is required.

Return Value

Returns a string with the hostname on success, otherwise false is returned.

Example:

The example below shows the usage of gethostname() function.

<?php
$name = gethostname();

echo "Host Name: $name";
?>

The output of the above code will be:

Host Name: acs-26-05-21

❮ PHP Network Reference

5