Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7616617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:56:00+00:00 2026-05-31T02:56:00+00:00

I got the following function while googling for bot behaviour. while i am using

  • 0

I got the following function while googling for bot behaviour. while i am using this code, i get error for eregi() expression. i am not an expert of regualar expression. since ereri( ) has been depreciated, i am getting the same error.

 function check_if_spider()
        {
            // Add as many spiders you want in this array
            $spiders = array('Googlebot', 'Yammybot', 'Openbot', 'Yahoo', 'Slurp', 'msnbot', 'ia_archiver', 'Lycos', 'Scooter', 'AltaVista', 'Teoma', 'Gigabot', 'Googlebot-Mobile');

            // Loop through each spider and check if it appears in
            // the User Agent
            foreach ($spiders as $spider)
            {
                if (eregi($spider, $_SERVER['HTTP_USER_AGENT']))
                {
                    return TRUE;
                }
            }
            return FALSE;
        }

how can i modify the code to make it workin? google search says it should be converted to preg_match(); being a newbee, i am at failure, although i tried at my end..can somebody guide me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:56:01+00:00Added an answer on May 31, 2026 at 2:56 am

    You aren’t actually using regular expressions (you’re matching literal strings) so there’s no need to use preg_match().

    Replace

    if (eregi($spider, $_SERVER['HTTP_USER_AGENT']))
    

    with

    if (strpos($spider, $_SERVER['HTTP_USER_AGENT']) !== FALSE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following code that I can't seem to get working: function drawTable($result)
Hello Everybody! I got the following error, while trying to test a code for
I have got the following very simple code: function init() { var articleTabs =
I have got the following issue, my function appends code to a string $string
I've got the following piece of Jquery: $(#collapse-menu > li > a).click(function() { $(this).toggleClass(expanded).toggleClass(collapsed).find(+
I've got the following jsp page and I'm using struts2-jquery-plugin-3.1.1 <script type=text/javascript> function openDialog()
I got following error... System.NullReferenceException: Object reference not set to an instance of an
I got the following error/warning while tring to install Kohana/SilverStripe. What does it mean
I got the following error message while compiling, but I'm sure I have the
In GCC I got the following error: aes.c: In function ‘copy_block’: aes.c:278: error: lvalue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.