Page 1 of 1

environment differences

Posted: Tue Mar 02, 2010 10:41 am
by sharmel
Hi, can anyone help me with this codes? I would like to print different text from different web browser using ereg() or preg_match() function.

I have tried like this but doesnt work:

<?php
$moz = $_SERVER['HTTP_USER_AGENT'];

if(ereg("mozila firefox",$moz))
{
echo "this is mozila";
}
else
{
echo " this is MSIE";
}
?>

Re: environment differences

Posted: Tue Mar 02, 2010 11:06 am
by Kurby
ereg

Searches a string for matches to the regular expression given in pattern in a case-sensitive way.

Warning
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.

Re: environment differences

Posted: Tue Mar 02, 2010 11:18 am
by AbraCadaver
Probably easier to use stripos():

Code: Select all

if(stripos($_SERVER['HTTP_USER_AGENT'], 'mozilla firefox') !== false)