0
if ((eregi('opera mini', $_SERVER['HTTP_USER_AGENT'])) == 1)

How can I convert this?

if ((preg_match('opera mini', $_SERVER['HTTP_USER_AGENT'])) == 1) 

The above does not work.

pgiecek
  • 7,508
  • 3
  • 35
  • 46
Reeecz3
  • 21
  • 1
  • 9
  • You don't REGEX which is expensive to find the first occurrence of a string. [`stristr`](http://php.net/manual/en/function.strstr.php) would work just fine. And you [shouldn't rely on `$_SERVER['HTTP_USER_AGENT']`](http://stackoverflow.com/questions/6465397/is-it-possible-for-serverhttp-user-agent-to-not-be-set) – Max Oct 13 '14 at 11:18

1 Answers1

0

You need to add the delimeters. I choose to use /, others choose ~ or #.

if ((preg_match('/opera mini/', $_SERVER['HTTP_USER_AGENT'])) == 1) 
ʰᵈˑ
  • 11,045
  • 2
  • 22
  • 47