PHP how to get the base domain/url?

Use SERVER_NAME.

echo $_SERVER['SERVER_NAME']; //Outputs www.example.com

Leave a Comment