我在搜索bot行爲時獲得了以下功能。當我使用此代碼時,我得到eregi()
表達式的錯誤。我不是調情表達的專家。由於ereri()
已折舊,我得到相同的錯誤。Eregi需要更換?
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;
}
我該如何修改代碼才能使其工作?谷歌搜索說,它應該被轉換爲preg_match();
是一個新手,我在失敗,雖然我嘗試在我的結局..可以有人指導我?
[將ereg表達式轉換爲preg]的可能副本(http://stackoverflow.com/questions/6270004/converting-ereg-expressions-to-preg) – mario 2012-03-11 23:38:54