How to detect robots and spiders with PHP?

Here is the simple function for detecting spiders and robots. It will return true or false.

function is_bot(){
    $bots = array(
        'Sogou web spider',
        'Yahoo! Slurp', 

   foreach($bots as $b){
      if( stripos( $_SERVER['HTTP_USER_AGENT'], $b ) !== false ) return true;
   return false;

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems. Protection Status