homepage Welcome to WebmasterWorld Guest from 54.196.168.78
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php - serving browser specific info
we hope to serve different meta tags based on browser...
iggy99




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

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

 

jatar_k




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved