ihaveaquestion
ihaveaquestion

Reputation: 33

How to detect the w3.org's bot in PHP?

I would like to detect w3c validator's bot in PHP. So if somebody try to validate my site on http://validator.w3.org , I would like to do something else in Php.

Upvotes: 3

Views: 529

Answers (1)

Fabian
Fabian

Reputation: 3495

function w3c(){
if((stristr($_SERVER["HTTP_USER_AGENT"],'w3c') === TRUE))
return true;
}

if(w3c()){
    // this is the w3c
}

And if you want to hide something from the w3c validator just use:

if(!w3c()){
    // this is not visible for the w3c validator
}

Upvotes: 3

Related Questions