environment differences

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sharmel
Forum Newbie
Posts: 1
Joined: Tue Mar 02, 2010 2:38 am

environment differences

Post 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";
}
?>
Kurby
Forum Commoner
Posts: 63
Joined: Tue Feb 23, 2010 10:51 am

Re: environment differences

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: environment differences

Post by AbraCadaver »

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.
Post Reply