Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 556
ihaveaquestion Avatar asked Dec 20 '25 18:12

ihaveaquestion


1 Answers

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
}
like image 90
Fabian Avatar answered Dec 22 '25 12:12

Fabian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!