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";
}
?>
environment differences
Moderator: General Moderators
Re: environment differences
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.
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.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: environment differences
Probably easier to use stripos():
Code: Select all
if(stripos($_SERVER['HTTP_USER_AGENT'], 'mozilla firefox') !== false)mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.