driz Posted June 9, 2008 Share Posted June 9, 2008 Please look at the following PHP code. It doesn't seem to be working, can you tell me what is wrong? Thanks. x <?phpfunction browser() { if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) echo '<p>You are using IE</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko/')) echo '<p>You are using Firefox</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit')) echo '<p>You are using Safari</p>'; } ?> Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted June 9, 2008 Share Posted June 9, 2008 I know JS can detect browsers really easilly, but idk how... try looking at this function and alter your code to follow itget_broswer()http://us2.php.net/manual/en/function.get-browser.php(Wow, I didn't realize PHP could get that much information about the user's browser! I just sort of spotted the function when I was looking at $_sever vars! ) Link to comment Share on other sites More sharing options...
driz Posted June 9, 2008 Author Share Posted June 9, 2008 Hmm sorry that doc hasn't helped, in fact! It's just confused me even more. x Link to comment Share on other sites More sharing options...
Ingolme Posted June 9, 2008 Share Posted June 9, 2008 It's not working? What is the output? Or is it returning an error? Link to comment Share on other sites More sharing options...
driz Posted June 9, 2008 Author Share Posted June 9, 2008 Their is no output! http://www.paperview.org/test.php Link to comment Share on other sites More sharing options...
vytas Posted June 9, 2008 Share Posted June 9, 2008 Im not really a PHP coder but doesn't a function need to be called? Link to comment Share on other sites More sharing options...
midnite Posted June 9, 2008 Share Posted June 9, 2008 Please look at the following PHP code. It doesn't seem to be working, can you tell me what is wrong? Thanks. x<?phpfunction browser() { if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) echo '<p>You are using IE</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko/')) echo '<p>You are using Firefox</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit')) echo '<p>You are using Safari</p>'; } ?> Hey try<?phpfunction browser() { if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) echo '<p>You are using IE</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko/')) echo '<p>You are using Firefox</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit')) echo '<p>You are using Safari</p>'; } browser();?> Link to comment Share on other sites More sharing options...
midnite Posted June 9, 2008 Share Posted June 9, 2008 Im not really a PHP coder but doesn't a function need to be called?Hi master, i believe that's the key point too Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted June 9, 2008 Share Posted June 9, 2008 Well, I should have looked at the page better, it only works if the browser.ini file is set... so forget my idea. Link to comment Share on other sites More sharing options...
driz Posted June 9, 2008 Author Share Posted June 9, 2008 Dam today has been a long day, can't believe I forgot to call the function :SThanks for the help. x Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.