Skip to content
Related Articles
Open in App
Not now

Related Articles

PHP | gethostname() Function

Improve Article
Save Article
  • Last Updated : 03 Sep, 2019
Improve Article
Save Article

The gethostname() function is an inbuilt function in PHP which returns the host or domain name for the local machine. This function is applicable after PHP 5.3.0 before that there was another function called php_uname function.


string gethostname( void )

Parameters: This function doesn’t accept any parameters.

Return Value: This function returns the host or domain name on success and FALSE on failure.

Note: This function is available for PHP 5.3.0 and newer version.

Below program illustrates the gethostname() function in PHP:


// Use gethostname() function to
// get the host name
echo gethostname();




My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!