How does php get the hostname of the current domain name?

how does php get the hostname of the current domain name?

for example, there is a url: http://m.news.example.com:1000/test/helloworld.php

.

use $_ SERVER ["SERVER_NAME"]; to get the current domain name (without port number), that is, m.news.example.com .
use $_ SERVER ["HTTP_HOST"]; to get the current domain name (with port number), that is, m.news.example.com:1000 .

question:
I just need the hostname news , how can I get it?

Php
Mar.09,2021

echo explode('.',$_SERVER['SERVER_NAME'])[1];
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb37d0-245a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb37d0-245a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?