Archive for the ‘Web Design’ Category
Blog HTML Validity and plug-ins
Written by simon on December 18, 2008 – 02:34 -
Maintaining the Wordpress blog valid to the declared HTML standard seems to be not very easy if many plug-ins are used. In fact, every plug-in contributes a piece of code to the page and sometimes breaks the HTML validity. Since plug-ins can be upgraded by a simple click in the dashboard, an error can be simply delivered and installed to your Blog. Thus, a re-check in a HML Validator of your choice is desireable after every new plugin upgrade. I prefer to use W3C Validator for checks.
Apparently, I realized running my monthly seitwert-check, that the one of my pages got errors because of one of the plug-in installed. This time it was Google Syntax Highlighter for WordPress by Peter Ryan. Instead of using the type="text/javascript" inside of script-tag, the class="javascript" is used. The bug could be easily fixed locally by replacing the corresponding pieces of code. Peter seems to be not interested anymore in maintaining the plug-in, since there is a long list of comments claiming and voting for the bug.
Especially, if you think of the fact, that the usage of invalid (X)HTML effects your page rank by search engines and other directories in a very negative way, such hidden standards violations should be avoided.
Tags: html validity, page rank, plugin, syntax highlighter, validator, w3C, WordPress, XHTML
Posted in HTML, SEO, Web Design, WordPress | No Comments »
Browser detection in PHP
Written by lexa on November 12, 2008 – 22:32 -
It was short time ago. I was sitting in my room and thinking about browser-problems in this great and sick world. Then I went to the kitchen to make a tea, but made a coffee, because I was thinking about another things. Just like the programmers of the browsers, they wanted to make a best browser ever, but they failed.
So, now about our problem. We want make our application working in all browsers, because it’s good to make it work everywhere. So we have to aks the user agent (basically the client program, not the agent Smith from Matrix), what browser are you using? And we want make it so flexible, that we can ask him this every time. For this purpose we introduce a function:
function getBrowser()
{
$ua = $_SERVER['HTTP_USER_AGENT']
if (strstr($ua,'Opera')) { // Opera
$browser = ereg_replace(".+\(.+\) (Opera |v){0,1}([0-9,\.]+)[^0-9]*","Opera\\2",$ua);
if(ereg('^Opera/.*',$ua)) {
$browser = ereg_replace("Opera/([0-9,\.]+).*","Opera \\1",$ua);
}
} elseif (strstr($ua,'MSIE')) { // MSIE
$browser=ereg_replace(".+\(.+MSIE ([0-9,\.]+).+", "Internet Explorer \\1",$ua);
} elseif (strstr($ua,'Firefox')) { // Firefox
$browser=ereg_replace(".+\(.+rv:.+\).+Firefox/(.*)", "Firefox \\1", $ua);
} elseif (strstr($ua,'Mozilla')) { // Mozilla
$browser=ereg_replace(".+\(.+rv:([0-9,\.]+).+","Mozilla \\1",$ua);
} else { // None of them.
$browser=$ua;
}
return $browser;
}
If we want our PHP script to show us the browser, we write:
echo(getBrowser());
Now we can see, what kind of browser is used and use it in our aplication:
if (getBrowser() == 'Internet Explorer 6.0') {
echo ("Please install another Browser");
}
Thats it!
Tags: browser, difference, firefox, mozilla, msie, opera, PHP
Posted in General, PHP, Web Design | No Comments »
