code: public static function getDomain($url = false)
      {
          if ($url) {
              preg_match('/([\w]+[.]){1,}[a-z]+/', $url, $matches);
  
              return isset($matches[0]) ? $matches[0] : false;
          }
  
          return $_SERVER['SERVER_NAME'];
      }
docs: Get the server name.
  
  @param string $url
  
  @return string|false → server name