Forum Moderators: coopster
- John
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];$capable_user_agents = array('Firefox',
'Opera',);
if(!in_array($_SERVER['HTTP_USER_AGENT'],$capable_user_agents))
{
echo 'unsupported technology message here';
}
else {
echo 'supported technology here';
}
Here is my guess with stristr though it does not work...
- John
<?php$useragent = $_SERVER['HTTP_USER_AGENT'];
$useragents = array('Firefox','Opera',);
if (strstr($useragents, $useragent))
{
echo 'your browser is supported';
}
else
{
echo 'fail';
}?>
[edited by: JAB_Creations at 3:50 pm (utc) on Jan. 5, 2007]
this works
<?
$useragent = $_SERVER['HTTP_USER_AGENT'];
$useragents = array('Firefox','MSIE');
$checkit = '';
$answer = '';
foreach ($useragents as $ua) {
$checkit = stristr($useragent,$ua);
if ($checkit === false) {
$answer = false;
} else {
$answer = true;
break;
}
}
echo '<p>',$useragent;
if ($answer) {
echo '<p>you can come in';
} else {
echo '<p>you are not welcome here';
}
?>