Welcome to WebmasterWorld Guest from 54.159.214.250

Forum Moderators: coopster & jatar k

php - serving browser specific info

we hope to serve different meta tags based on browser...

   
7:10 pm on Apr 19, 2002 (gmt 0)

10+ Year Member



we hope to serve different meta tags based on browser type in an effort to gain favorable se rankings -

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">');
}

9:25 pm on Apr 19, 2002 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



something like this might work but I am sure someone will have a better answer and this is a bit of a lazy attempt. I don't really understand why you want to do this but this would work.

$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\">";
}

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month