Reputation: 33
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
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