phppreg-matcheregi

PHP's eregi to preg_match conversion


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.


Solution

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

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