Get the host name in PHP

Description

The following code shows how to get the host name.

Example


/*from  w w w  .j  a v  a2  s. c o  m*/
//gethostname() example


<?php
echo gethostname(); // may output e.g,: sandie

// Or, an option that also works before PHP 5.3
echo php_uname('n'); // may output e.g,: sandie
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions