How to get the first subdomain with PHP?

前端 未结 5 849
广开言路
广开言路 2020-12-11 23:10

I have a static domain of dev.example.com with wildcard subdomains like so *.dev.example.com.

I need to detect the name of the current wild

5条回答
  •  孤街浪徒
    2020-12-11 23:24

    From PHP 5.3 you can use strstr() with true parameter

    echo strstr('sub.dev.example.com', '.', true); //prints sub
    

    Original link

提交回复
热议问题