The Wayback Machine - https://web.archive.org/web/20230422123542/https://www.geeksforgeeks.org/php-gethostname-function/
Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

PHP | gethostname() Function

Improve Article
Save Article
Like Article
author
gekcho
proficient
149 published articles
Improve Article
Save Article
Like 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.

Syntax:

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:

Program:




<?php
  
// Use gethostname() function to
// get the host name
echo gethostname();
  
?>

Output:

pppContainer

Reference: https://www.php.net/manual/en/function.gethostname.php

My Personal Notes arrow_drop_up
Last Updated : 03 Sep, 2019
Like Article
Save Article
Similar Reads
Related Tutorials