<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webmaster-Source &#187; Browser Detection</title>
	<atom:link href="https://www.webmaster-source.com/tag/browser-detection/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Thu, 24 Aug 2017 02:01:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>No More CSS Hacks: PHP Browser Detection</title>
		<link>https://www.webmaster-source.com/2008/05/28/no-more-css-hacks-php-browser-detection/</link>
		<comments>https://www.webmaster-source.com/2008/05/28/no-more-css-hacks-php-browser-detection/#comments</comments>
		<pubDate>Wed, 28 May 2008 11:27:59 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Browser Detection]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[User Agent]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=568</guid>
		<description><![CDATA[You can&#8217;t make your page render correctly in every browser. It just isn&#8217;t possible. Between several versions of the bug-ridden Internet Explorer (why can&#8217;t Microsoft just switch to Gecko or WebKit?) and a sprinkling of older browsers, there are too many bases to cover. Internet Explorers 6 and prior are notorious for their bad CSS [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>You can&#8217;t make your page render correctly in every browser. It just isn&#8217;t possible. Between several versions of the bug-ridden Internet Explorer (why can&#8217;t Microsoft just switch to Gecko or WebKit?) and a sprinkling of older browsers, there are too many bases to cover. Internet Explorers 6 and prior are notorious for their bad CSS implementations (IE7 is better, but it still has a ways to go), and if you tweak your CSS to look right in them, chances are you&#8217;ll create another problem somewhere else. When does the endless cycle of fixing things end? When you give up and say &#8220;it&#8217;s just not going to work in all browsers.&#8221; Now, you don&#8217;t want to give up too soon, since there are still a lot of people on IE6, but you have to know when to call it quits.</p>
<p>And don&#8217;t forget about mobile browsers. Sure, their improving, like Apple&#8217;s mobile Safari browser on the iPhone, but it&#8217;s still a lot easier to use a <a href="http://iphone.cnet.com/">mobile-specific version</a> of a site than zooming and scrolling around on the tiny screen.</p>
<p>As usual, <a href="http://php.net">PHP</a> has a solution. That solution comes in the form of the global variable <code>$_SERVER['HTTP_USER_AGENT']</code>. It holds a string that contains a bit of information about the browser and platform a user us using. By searching through the string, you can figure out what browser your users are browsing with, and write-in the right code depending on the browser. You can do this in as simple, or as complicated, of a way as you want.<span id="more-568"></span></p>
<p>You can simply write-in a call to a different stylesheet, or in the case of the iPhone, an entirely different template. Using echo, header(), and include(), you have plenty of different ways to do this. Here is a simple example:</p>
<p><code> $browser = strtolower($_SERVER['HTTP_USER_AGENT']);</code></p>
<p><code>if (strpos($browser, 'msie')) {<br />
include 'internetexploder.php';<br />
}<br />
else {<br />
include 'normal.php';<br />
}</code></p>
<p><code>?&gt;</code><br />
This is a great way to support old browsers. You can just feed them a simpler template.</p>
<h3>Further Reading</h3>
<ul>
<li><a href="http://www.zytrax.com/tech/web/browser_ids.htm">Browser ID (User-Agent) Strings</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2008/05/28/no-more-css-hacks-php-browser-detection/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-06-09 01:15:47 by W3 Total Cache
-->