Are there specific coding practices or functions in PHP that can negatively impact performance, such as gethostbyaddr() for host queries?

Using functions like gethostbyaddr() for host queries can negatively impact performance because they involve DNS lookups which can be slow and unreliable. To improve performance, it's recommended to avoid using such functions and instead cache the results if needed.

// Example of caching DNS lookups
$cache = [];

function getHostIp($host) {
    global $cache;

    if (isset($cache[$host])) {
        return $cache[$host];
    }

    $ip = gethostbyname($host);
    $cache[$host] = $ip;

    return $ip;
}

// Usage
$ip = getHostIp('example.com');
echo $ip;