PHP | gethostname() Function

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

pppContainer

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



My Personal Notes arrow_drop_up

I am unrecognized crazy being with random thoughts

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.