You are here

function _shurly_gethostbyname in ShURLy 8

Same name and namespace in other branches
  1. 6 shurly.module \_shurly_gethostbyname()
  2. 7 shurly.module \_shurly_gethostbyname()

Wrapper function for PHP's `gethostbyname()`.

This function should be used, when multiple encapsulated code parts need to resolve a hostname.

@staticvar array $resolved_hosts Array of `gethostbyname()` return values.

Parameters

string $hostname: Hostname to resolve.

Return value

string Resolved host address on success or the input $hostname on failure.

3 calls to _shurly_gethostbyname()
shurly_host_is_local in ./shurly.module
Check whether the given resolved host is the localhost.
shurly_host_is_private in ./shurly.module
Check whether the given hostname matches a private IP address.
shurly_host_is_resolveable in ./shurly.module
Check whether the input $hostname can be resolved to a valid IP address.

File

./shurly.module, line 666
Description http://www.youtube.com/watch?v=Qo7qoonzTCE.

Code

function _shurly_gethostbyname($hostname) {
  static $resolved_hosts = [];
  if (!isset($resolved_hosts[$hostname])) {
    $resolved_hosts[$hostname] = gethostbyname($hostname);
  }
  return $resolved_hosts[$hostname];
}