检查客户端是否在首页?

How can I check if the client is on the front page?

What I've tried

$CURRENT_URL = "http://". $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if($CURRENT_URL == "http://domain.com")
{
...
}

Just check the request URI:

if ($_SERVER["REQUEST_URI"] === "/")

$_SERVER['REQUEST_URI'] will always begin with a /. Even if you are on the home page. So you'll add this slash the domain you are testing against:

$CURRENT_URL = "http://". $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if($CURRENT_URL == "http://domain.com/") { // ...