Forum Moderators: coopster
found this from another microsoft *.asp group -
how would such an example be used in php?
many thanks!
var sBrowser = "" + Request.ServerVariables ( 'HTTP_USER_AGENT' );
if ( -1 == sBrowser.indexOf ( 'Mozilla' ) && -1 == sBrowser.indexOf ( 'Opera' ) )
{
// an unknown browser - probably a spider
Out ( '<meta name="Keywords" content="Important phrase or
keyword, another one">' );
Out ( '<meta name="Description" content="A full description of
your site goes here.">' );
}
else {
// a browser - show some junk to make them think we're idiots
Out ( '<meta name="Keywords" content="some throwaway
words">' );
Out ( '<meta name="Description" content="A short description">');
}
$browser = $HTTP_USER_AGENT;
$arrBrowser = array("mozilla","opera","MSIE") // put all the UA's in here
$test = "no";
$counter = 0;
while (isset($arrBrowser[$counter]))
{
if (strstr($browser,$arrBrowser[$counter])) $test = "yes";
$counter++;
}
if ($test == "yes") // then we have a browser from our array
{
echo "<meta name=\"Description\" content=\"Important phrase or keyword, another one\">";
echo "<meta name=\"Keywords\" content=\"Important phrase or keyword, another one\">";
} else {
echo "<meta name=\"Description\" content=\"Some other content\">";
echo "<meta name=\"Keywords\" content=\"Some other keywords\">";
}