Check for domain extension with PHP or JS

javascript, php, tld

Solution

To get the domain extension use php's pathinfo

$extension = pathinfo($_SERVER['SERVER_NAME'], PATHINFO_EXTENSION);

if($extension == "de")
{
echo "this is a german site";
}

Also see: $_SERVER

Problem

First of all I am a php beginner so please be as specific as possible. Basically I want a php/javascript that does the following: if the domain has a .de extension then add the text "this is a german site" else add the text "this is not a german site" it's also ok if you do it with the lang="de-DE" instead of the domain extension.

Original source