How to get subdomain URL
Here's a one-liner to get the subdomain: $subdomain = join('.', explode('.', $_SERVER['HTTP_HOST'], -2)) explode with the limit parameter of -2 will split the string on each dot, ignoring the last two elements. If there are two or fewer elements, it returns an empty array. join will assemble the resulting array back into a dot delimited string. In case you have multiple subdomains set, e.g. foo...
Code Snippets/PHP
2021. 12. 9. 07:52