<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7264343268942025532</id><updated>2012-01-23T13:19:12.547+01:00</updated><category term='images'/><category term='simplicity'/><category term='Google Maps'/><category term='minify css'/><category term='jQuery'/><category term='javascript'/><category term='mysql'/><category term='minify javascript'/><category term='php'/><category term='minify code'/><category term='assembler'/><category term='preloading'/><category term='first'/><category term='goto'/><category term='sql injection'/><category term='chrome'/><category term='browsers'/><category term='asm'/><category term='stackoverflow'/><category term='firefox'/><category term='box model'/><category term='css'/><category term='sql'/><category term='formchecking'/><category term='bandwidth issues'/><category term='html'/><category term='performance'/><category term='xhtml'/><category term='string_escaping'/><category term='opera'/><category term='database'/><title type='text'>Web Developer Hobo</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-7513350479268413501</id><published>2010-03-20T03:22:00.003+01:00</published><updated>2010-03-20T19:43:25.161+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='browsers'/><category scheme='http://www.blogger.com/atom/ns#' term='chrome'/><category scheme='http://www.blogger.com/atom/ns#' term='opera'/><title type='text'>A difference between Chrome, Opera and Firefox</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'A difference between Chrome, Opera and Firefox';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2010/03/difference-between-chrome-opera-and.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;While working on the project they gave us in college, I came across yet another fun example of the difference between the big browsers.&lt;br /&gt;&lt;br /&gt;Firefox 3.6.2: &lt;a href="http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/Blogpost pics/Firefox_test.png" target="new"&gt;Firefox Screenshot&lt;/a&gt;&lt;br /&gt;Opera 10.50: &lt;a href="http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/Blogpost pics/Opera_test.png" target="new"&gt;Opera Screenshot&lt;/a&gt;&lt;br /&gt;Chrome 5.0.322.2: &lt;a href="http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/Blogpost pics/Chrome_test.png" target="new"&gt;Chrome Screenshot&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;IE8 gave the same result as Chrome.&lt;br /&gt;&lt;br /&gt;Save this code and open the file in those 3 browsers if you wanna try for yourself.&lt;br /&gt;Or click this link: &lt;a href="http://koendegroote.ikdoeict.be/test.html" target="new"&gt;Link&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:html;wrap-lines:false"&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xml:lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt; &amp;lt;title&amp;gt;Test&amp;lt;/title&amp;gt;&lt;br /&gt; &amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=utf-8&amp;quot; /&amp;gt;&lt;br /&gt;    &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;        /* CSS RESET*/&lt;br /&gt;        html, body, div, h1, h2, h3, h4, ul, ol, li, form, fieldset,&lt;br /&gt;        input, textarea {&lt;br /&gt;            margin: 0;&lt;br /&gt;            padding: 0;&lt;br /&gt;            font-size: 100%;&lt;br /&gt;        }&lt;br /&gt;        ul {list-style: none;}&lt;br /&gt;        img, fieldset {border: 0;}&lt;br /&gt;        h1, h2, h3, h4 {font-weight: normal;}&lt;br /&gt;        em {font-style: italic;}&lt;br /&gt;        strong {font-weight: bold;}&lt;br /&gt;&lt;br /&gt;        #header{&lt;br /&gt;            outline: solid 2px red;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #headertext{&lt;br /&gt;            max-width: 200px;&lt;br /&gt;            height: 40px;&lt;br /&gt;            border: dotted 3px green;&lt;br /&gt;            float: left;&lt;br /&gt;            font-weight: bold;&lt;br /&gt;            font-size: 1.8em;&lt;br /&gt;        }&lt;br /&gt;    &amp;lt;/style&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;div id=&amp;quot;main&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;div id=&amp;quot;header&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;div id=&amp;quot;headertext&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;h2&amp;gt;Foo in the bar&amp;lt;/h2&amp;gt;&lt;br /&gt;            &amp;lt;/div&amp;gt;&lt;br /&gt;            &amp;lt;div id=&amp;quot;navbar&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;h3&amp;gt;Foo in the bar&amp;lt;/h3&amp;gt;&lt;br /&gt;            &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-7513350479268413501?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/7513350479268413501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=7513350479268413501&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7513350479268413501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7513350479268413501'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2010/03/difference-between-chrome-opera-and.html' title='A difference between Chrome, Opera and Firefox'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-8915871885107775649</id><published>2010-01-08T06:24:00.003+01:00</published><updated>2010-03-20T03:33:40.570+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='simplicity'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>Querying the servers</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Querying the servers';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2010/01/querying-the-servers.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;When you build a website, you'll probably be using these pieces of technology:&lt;ul&gt;&lt;li&gt;Client-side languages like &lt;abbr title="Hyper Text Markup Language"&gt;HTML&lt;/abbr&gt;, &lt;abbr title="Cascading Style Sheets"&gt;CSS&lt;/abbr&gt; and JavaScript&lt;/li&gt;&lt;li&gt;Server-side languages like &lt;abbr title="PHP: Hypertext Preprocessor"&gt;PHP&lt;/abbr&gt;, ASP.NET, etc...&lt;/li&gt;&lt;li&gt;A relational database like MySQL, MSSQL, PostreGreSQL, etc...&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Depending on how active a certain website is, the database will get more or less queries. Some fellow students of mine appear to think that this is &lt;strong&gt;completely&lt;/strong&gt; dependent on the activity of the user. I am here to show that it is not.&lt;br /&gt;&lt;br /&gt;Let's take a look at this drawing I made:&lt;br /&gt;&lt;img src="http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/bd83d86f956e2b6ee90787208abac6095a2.png" width="463" height="367" alt="A short display of how multiple queries for each piece of data are more stressful than one query to get multiple pieces of data" /&gt;&lt;br /&gt;Granted, the query for the 5 pieces of data at once might be a tiny bit bigger, but it makes no significant difference. And this is &lt;strong&gt;only&lt;/strong&gt; 5 times. Suppose it were 20, or 100. The difference would be &lt;em&gt;a lot&lt;/em&gt; bigger. And that's not taking into account that this is only one user doing one thing. The one user can spend hours doing many more things and besides that one user, many other users will also be doing this. The implications are enormous.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One might think this is all very straightforward. The logic is simple and there's no refuting it. Yet it keeps happening. Because in a lab-environment, performance is not an issue. Testing remains limited to functionality and endurance is mostly ignored. The remarks I've heard from various students and people on the internet boils down to: &lt;cite&gt;it's working under this condition, so I'm not going to bother with it anymore&lt;/cite&gt;&lt;br /&gt;&lt;br /&gt;In conclusion, I think the drawing speaks for itself. Performance is always an issue, and taking the stress of your system can certainly improve it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-8915871885107775649?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/8915871885107775649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=8915871885107775649&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/8915871885107775649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/8915871885107775649'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2010/01/querying-servers.html' title='Querying the servers'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/th_bd83d86f956e2b6ee90787208abac6095a2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-260234843548955158</id><published>2009-09-25T22:42:00.014+02:00</published><updated>2009-10-01T15:46:38.017+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Variable variables</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    bigtweet_prefix = 'RT @Vordreller';&lt;br /&gt;    bigtweet_title = 'PHP - Variable variables';&lt;br /&gt;    bigtweet_url = 'http://webdevhobo.blogspot.com/2009/09/variable-variables.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget1.bigtweet.com/widgets/button1.js?wid=4a9f1689e574f059&amp;pid=4ac4b02753a5343c&amp;bl=Bigtweet&amp;bsnc=FFFFFF&amp;bsnbac=4876FF&amp;bshc=4876FF&amp;bshbac=FFFFFF&amp;bsnboc=00008B&amp;ff=0"&gt;&lt;/script&gt;Since I'm not researching new things right now, due to my total lack of initiative, I'm gonna post something on things I already know which I believe to be useful.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Variables&lt;/h1&gt;To explain this, I need the reader to get into a certain state of mind.&lt;br /&gt;To be brief, think of a variable as a cardboard box in which you put things. You can have many boxes like this, the "variable" thing about them being the name you give the box.&lt;br /&gt;&lt;br /&gt;And that's what I'm gonna be working with here. Putting a box inside a box inside a box... and so on.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Variable variables&lt;/h1&gt;Which is a fancy name for what I said just now. Every variable has 2 basic things in common with all other variables:&lt;ol&gt;&lt;li&gt;A name, by which it can be identified. We need to know which box we need.&lt;/li&gt;&lt;li&gt;Content. You need to put something in the box(you can leave it empty if you want).&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;PHP example:&lt;pre class="brush:php;wrap-lines:false"&gt;$number = 6;&lt;br /&gt;echo $number //outputs 6 on the screen&lt;/pre&gt;Simple enough. Now watch this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:php;wrap-lines:false"&gt;$a = 'test';&lt;br /&gt;$$a = 'testing this test';&lt;br /&gt;echo $test; // This will output: "testing this test"&lt;/pre&gt;You might be asking: "but where did the &lt;font face="consolas"&gt;$test&lt;/font&gt; variable come from?"&lt;br /&gt;&lt;br /&gt;That is what variable variables is all about.&lt;br /&gt;&lt;br /&gt;To understand this, remember what I said earlier about "a box inside a box inside a box...". We have 2 dollar signs, so we have 2 boxes. Starting from left to right, you have the biggest and final box, then the box just a bit smaller, and so on, until you reach the last box. What happened is that I removed the smallest box and used its content to name the next box.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Note&lt;/strong&gt;: You can't pick a random order. You can use an infinite amount of dollar signs(boxes), but when you're going to determine what the final variable will be, you have to start doing the replacement from right to left. The smallest box gets deleted first and it keeps going like that until you finally reach the biggest box.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I defined the variable &lt;font face="consolas"&gt;$a = 'test';&lt;/font&gt;. So the content of &lt;font face="consolas"&gt;$a&lt;/font&gt; is &lt;font face="consolas"&gt;test&lt;/font&gt;&lt;br /&gt;Since we removed a box, we have to remove a dollar sign and the variable-name connected to it. We then replace it with the content of that variable. And thus birth is given to the &lt;font face="consolas"&gt;$test&lt;/font&gt; variable.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Note&lt;/strong&gt;: The smart reader will have asked him/herself this already: "what happens if I do this with many variables, but in the middle of the line, there's a typo?"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To be honest, I'm not entirely sure. In PHP, an unknown variable is treated as an empty string. So if you make a typo somewhere and you get a reference to a variable that hasn't been created yet, it should be replaced with an empty string of text. That will probably create an error or a warning, I'm not sure. Either way, since the variable that you'll be calling in the end doesn't exist, that too will be replaced by an empty string of text.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Functions too&lt;/h1&gt;You can pull this trick with functions as well. How? Because functions are never preceded by dollar signs. If php sees the () signs, it knows there's a function. But what if this happens:&lt;pre class="brush:php;wrap-lines:false"&gt;$function_name();&lt;/pre&gt;Well, the parser will assume there's a variable somewhere name "function_name". It will look up the content and replace it, same way you've witnessed before.&lt;br /&gt;&lt;br /&gt;So if you have this:&lt;pre class="brush:php;wrap-lines:false"&gt;function test() {&lt;br /&gt;  echo "hello world";&lt;br /&gt;}&lt;br /&gt;$function_name = 'test';&lt;br /&gt;$function_name();//outputs "hello world"&lt;/pre&gt;The parser will look for a function called test(). Simple as that. And once again, you can keep going with this. The depth is unlimited(theoretically).&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;What do you use it for&lt;/h1&gt;You can do anything you want with it really.&lt;br /&gt;Something I use this for is easy creation of variables to represent the content of database entries.&lt;br /&gt;&lt;br /&gt;For instance, suppose you have a database table with these columns:&lt;br /&gt;&lt;br /&gt;username | email | gender |age | married | number_of_children | street | province | etc&lt;br /&gt;&lt;br /&gt;And you're viewing the profile of a single person. Image having to type all the variables. Seems normal? Now check this:&lt;pre class="brush:php;wrap-lines:false"&gt;&lt;br /&gt;$vars = array('username','email','gender','age','married','number_of_children','street','province','etc');//or some function that calls the column names for you&lt;br /&gt;  foreach($vars as $var) {&lt;br /&gt;    $$var = $sql-&amp;gt;getUserInfo($user_id,$var);//user_id to be obtained at some earlier point&lt;br /&gt;  }&lt;/pre&gt;&lt;br /&gt;A bunch of variables will be created for the specific user_id.&lt;br /&gt;This principle becomes more and more useful with every extra column you need. If you have a function that can call all the columns of a certain table, you'll have the variables for all the columns you need (and those you don't need too, keep that in mind).&lt;br /&gt;&lt;br /&gt;That's about all I have to say on the subject. Thanks for reading.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-260234843548955158?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/260234843548955158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=260234843548955158&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/260234843548955158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/260234843548955158'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/09/variable-variables.html' title='Variable variables'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-6095096877231324240</id><published>2009-08-17T14:48:00.014+02:00</published><updated>2010-03-20T03:33:29.634+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='string_escaping'/><title type='text'>escaping characters in PHP</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'escaping characters in PHP';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/08/escaping-characters-in-php.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;Recently this PHP function was introduced to me:&lt;pre class="brush:php;wrap-lines:false"&gt;mysql_real_escape_string()&lt;/pre&gt;I hadn't heard of it before.&lt;br /&gt;&lt;br /&gt;To escape strings, I'm used to using &lt;pre class="brush:php;wrap-lines:false"&gt;addslashes()&lt;/pre&gt;&lt;br /&gt;I'm told that the difference in the mysql function is that it is dependent on the MySQL server settings.&lt;br /&gt;&lt;br /&gt;I have a standard install on this machine, with no settings altered whatsoever. I decided to do a simple test, with all the characters my keyboard can produce:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:php;wrap-lines:false"&gt;$link = mysql_connect($dbhost, $dbuser, $dbpw);&lt;br /&gt;mysql_select_db($dbname, $link);&lt;br /&gt;&lt;br /&gt;$test = &amp;quot;|@#[^{}&amp;sup3;1234567890&amp;deg;_-)&amp;agrave;&amp;ccedil;!&amp;egrave;&amp;sect;('\&amp;quot;&amp;eacute;&amp;&amp;sup2;AZERTYUIOP&amp;uml;*$^poiuytreza&amp;euro;[]&amp;pound;%MLKJHGFDSQqsdfghjklm&amp;ugrave;&amp;micro;&amp;acute;`&amp;gt;WXCVBN?./+=:;,nbvcxw&amp;lt;\~&amp;quot;;&lt;br /&gt;echo addslashes($test);&lt;br /&gt;echo mysql_real_escape_string($test);&lt;/pre&gt;&lt;br /&gt;The output for both functions is identical. Here's a screenshot:&lt;br /&gt;&lt;img src="http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/escaping.png" alt="Screenshot containing the output of both functions" width="639" height="62" /&gt;&lt;br /&gt;&lt;br /&gt;I have no knowledge of extra settings that might influence the function. So I'm stumped. If anybody ever reads this and knows of a way to influence the behavior of this function, feel free to let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-6095096877231324240?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/6095096877231324240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=6095096877231324240&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/6095096877231324240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/6095096877231324240'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/08/escaping-characters-in-php.html' title='escaping characters in PHP'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://i637.photobucket.com/albums/uu91/Vordreller/blogspot/th_escaping.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-4313795032734280334</id><published>2009-08-16T22:51:00.015+02:00</published><updated>2010-03-20T03:33:20.703+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='sql injection'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='formchecking'/><title type='text'>Formchecking in PHP</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Formchecking in PHP';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/08/prepared-statements-in-php.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;I recently asked a question on &lt;a href="http://stackoverflow.com/questions/1285146/" target="new" title="Link to the question"&gt;Stackoverflow&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I was a bit confused over a concept in programming/web-development I had never seen before, which turned out to be "Abstraction". I was provided with some good answers.&lt;br /&gt;&lt;br /&gt;Several people mentioned that my code didn't look like it was checked for errors pretty well. The post has some long answers and my original one got pretty long too, so I decided to elaborate here.&lt;br /&gt;&lt;br /&gt;I should note that my native language is Dutch. Most variable names will be in dutch, though some resemble their English counter-part. Though I'll be re-writting some of it in English randomly.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;register.php&lt;/h3&gt;&lt;br /&gt;The HTML of this page contains a hidden field with the name 'postback'.&lt;br /&gt;&lt;pre class="brush:html;wrap-lines:false"&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;postback&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;submit&amp;quot; name=&amp;quot;btnOk&amp;quot; id=&amp;quot;btnOk&amp;quot; value=&amp;quot;Register&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;input type=&amp;quot;reset&amp;quot; name=&amp;quot;reset&amp;quot; value=&amp;quot;Reset&amp;quot; /&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In the source code, you'll find this:&lt;pre class="brush:php;wrap-lines:false"&gt;if(isset($_REQUEST['postback'])) {&lt;br /&gt;    $allOk = true;&lt;br /&gt;    ...&lt;/pre&gt;This is where the formchecking begins. What we were taught to do, let's leave whether this is a good or bad practice out of it for a second, is to control the input of every field for possible SQL injection, XSS and other stuff.&lt;br /&gt;&lt;br /&gt;The basic idea is that the moment something bad is detected, the allOk variable is set to &lt;i&gt;false&lt;/i&gt; and can never be set to &lt;i&gt;true&lt;/i&gt; again. &lt;br /&gt;&lt;br /&gt;Here are a couple of examples of SQL injections we got from our instructor:&lt;pre class="brush:sql;wrap-lines:false"&gt;admin'--&lt;br /&gt;' OR 1=1--&lt;br /&gt;' UNION SELECT 1, 'hackerX', 'letmein', 1--&lt;br /&gt;' HAVING 1=1--&lt;br /&gt;' GROUP BY users.id HAVING 1=1--&lt;br /&gt;' GROUP BY users.id, users.login HAVING 1=1--&lt;br /&gt;' UNION SELECT SUM(login) FROM users--&lt;br /&gt;'; INSERT INTO users VALUES(666, 'hacker', 'letmein', 0xffff)--&lt;br /&gt;' UNION SELECT @@version,'1','1','1'--&lt;br /&gt;' UNION SELECT MIN(login),1,1,1 FROM users WHERE login&amp;gt;'a'--&lt;br /&gt;' UNION SELECT MIN(login),1,1,1 FROM users WHERE login&amp;gt;'admin'--&lt;br /&gt;' UNION SELECT password,1,1,1 FROM users WHERE login='admin'--&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So how do I check my forms? The way I remember doing it most. And this is how:&lt;br /&gt;&lt;h3&gt;Step 1&lt;/h3&gt;&lt;br /&gt;Using $_POST[], I make all the variables I need.&lt;br /&gt;Example:&lt;pre class="brush:php;wrap-lines:false"&gt;$naam = addPostSlashes($_POST['naam']);&lt;br /&gt;$straat = addPostSlashes($_POST['straat']);&lt;br /&gt;$paswoord = addPostSlashes($_POST['pasw']);&lt;br /&gt;...&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;addPostSlashes()&lt;/b&gt; is a function that checks if the php.ini file has magic quotes enabled or not. If not it applies the addslashes() method and in the other case it's been done already.&lt;br /&gt;&lt;br /&gt;I saw people mentioning the mysql_real_escape_string() function. I looked it up on PHP.net and compared it to the addslashes() method. The documentation itself doesn't show a lot of difference and some debugging didn't either, though I haven't tried the SQL injections yet. I doubt they'd have created mysql_real_escape_string() if it does the exact same thing as an existing function.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Part 2 - Regular Expressions&lt;/h3&gt;&lt;br /&gt;I use a couple of regular expressions to test the variables.&lt;br /&gt;&lt;pre class="brush:php;wrap-lines:false;"&gt;$rexSafety = '/^[^&amp;lt;,&amp;quot;@$?=&amp;gt;|;#]+$/i';&lt;br /&gt;$rexMail = '/^[a-z0-9\._]+@([a-z0-9-_]+\.)+[a-z]{2,3}$/i';&lt;/pre&gt;&lt;br /&gt;I'd like to mention that the Regular Expressions you see here have been tested and work. The only tiny problem I'm having is with the first one, which doesn't seem to allow empty strings. Which can be a pain for non-required fields in a registration form.&lt;br /&gt;&lt;br /&gt;The first one is used as follows:&lt;pre class="brush:php;wrap-lines:false;"&gt;if(!preg_match($rexSafety,stripslashes($naam))){&lt;br /&gt;  $allOk = false;&lt;br /&gt;  $naamError = '&amp;nbsp;please don\'t use &lt; , @ # - &gt;  $ ; = | or "';&lt;br /&gt;}&lt;/pre&gt;I'm checking if any of these characters are present in the received string and if there is even one, the entire registration gets canceled. Next to the field where the error was found appears a message explaining what went wrong to the user. In this case, asking to please not use any of the following characters.&lt;br /&gt;&lt;br /&gt;Rest assured, a potential customer accidentally filling in something wrong won't have to re-write the whole thing. The page is reloaded not only with the explanations, but also has all the previously entered text in the correct place, with the exception of passwords not being reloaded.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thinking about this, I realize that anyone with a @ in their password is gonna be pretty miffed at me for doing this. As far as I'm aware, you can't escape a @ or a # sign and they can both be used in SQL injection. Please correct me if I'm wrong. And should you do so, please refrain from such comments as: "what a horrible piece of coding" and other such comments. I'm here to learn, not to get insulted.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Part 3 - All Ok!&lt;/h3&gt;&lt;br /&gt;Once everything is checked and no errors are found, I call upon the SQL class and the User class. They respectively represent the SQL actions I want to perform and the actions on the User I wish to perform. I should perhaps mention that the register.php file has a &lt;b&gt;require&lt;/b&gt; statement for both classes at the top of the file.&lt;br /&gt;&lt;br /&gt;So this happens:&lt;br /&gt;&lt;pre class="brush:php;wrap-lines:false"&gt;$sql = new SqlObject();&lt;br /&gt;$newUser = new User('',$naam,sha1($passw),...);&lt;br /&gt;$sql-&gt;addUser($newUser);&lt;/pre&gt;All of those are escaped. Just have to remember it's all stored with escaped characters, as to make sure logging in works.&lt;br /&gt;&lt;br /&gt;Let's look at an example of what the User.class.php file looks like:&lt;pre class="brush:php;wrap-lines:false"&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;class User {&lt;br /&gt;  // members&lt;br /&gt;  var $id;&lt;br /&gt;  var $name;&lt;br /&gt;  var $password;&lt;br /&gt;  &lt;br /&gt;  // constructor&lt;br /&gt;  function User($id=-1,$name='',$password='') {&lt;br /&gt;      $this-&gt;id = $id;&lt;br /&gt;      $this-&gt;name = $name;&lt;br /&gt;      $this-&gt;password = $password;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/pre&gt;This is shortened, but you get the general idea I hope.&lt;br /&gt;&lt;br /&gt;The SQL class has &lt;pre class="brush:php;wrap-lines:false"&gt;require "User.class.php";&lt;/pre&gt;written on the first line, which enables it to use instances of the User class.&lt;br /&gt;&lt;br /&gt;Which brings us to the addUser() function:&lt;pre class="brush:php;wrap-lines:false"&gt;function addUser($user){&lt;br /&gt;  $insQuery = 'INSERT INTO users(naam,paswoord,...)';&lt;br /&gt;  $insQuery.= " VALUES ('".$user-&gt;naam."', '".$user-&gt;paswoord."')";&lt;br /&gt;  @mysql_query($insQuery) or showError("user insert failed");&lt;br /&gt;}&lt;/pre&gt;I highly doubt this but I'll mention it anyway: the ... are meant to indicate more fields, not actual input.&lt;br /&gt;&lt;br /&gt;So that's how we've been taught to do it. That is to say, we were shown the basics and were allowed to choose our own way of implementing it.&lt;br /&gt;I read the term "prepared statement" a few times. I looked it up and it looks interesting enough.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To answer Mr. Vinko's example: the string &lt;b&gt;John O'Donell&lt;/b&gt; will be entered into the database as &lt;b&gt;John O\'Donell&lt;/b&gt;, that is true. Your concern seems to be that the escaping of the characters should happen at the insertion, and not during the checking for SQL injections(and similar stuff). To be honest, I've never considered doing this, because of the simple reason that it's not the way I did it the first time I did this type of formchecking. The fact that it worked, was enough for me untill now. This whole ordeal has gotten me thinking, and I'm beginning to believe I'm mixing up a few things.&lt;br /&gt;&lt;br /&gt;EDIT:&lt;br /&gt;I read all the things most of you said and it's starting to make sense. I can divide it all into 2 basic steps now&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Check for faulty input/possible injections without escaping anything&lt;/li&gt;&lt;li&gt;If everything checks out, send it to the PHP that handle database insertion and escape it there.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;That's what I think this all comes down to. I hope I got it right this time...&lt;br /&gt;&lt;br /&gt;I hope this wasn't too long and I realise this was more of an explanation to certain people than a proper blog entry, but I did what I said I'd be doing when I made my first post on this blog: learning. If anyone has any pointers or tips on the subject of formchecking or prepared statements, feel free to tell me.&lt;br /&gt;&lt;br /&gt;Though if you choose to do so, please don't say stuff like "That's a bad practice, the way I do it is better!" and the walk off without even offering an example. If you're gonna say I'm wrong or it could be better, then take the time to prove it. Offer me a good reasoning and I will listen/read. I'm not the kind of guy who sticks to what he believes no matter what for fear of new things, I just hope the rest of you out there aren't either.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-4313795032734280334?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/4313795032734280334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=4313795032734280334&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/4313795032734280334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/4313795032734280334'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/08/prepared-statements-in-php.html' title='Formchecking in PHP'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-2337539818783479226</id><published>2009-06-06T18:43:00.016+02:00</published><updated>2010-03-20T03:33:10.649+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stackoverflow'/><category scheme='http://www.blogger.com/atom/ns#' term='preloading'/><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='images'/><category scheme='http://www.blogger.com/atom/ns#' term='jQuery'/><title type='text'>Efficient image preloading in JavaScript</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Image preloading in Javascript';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/06/efficient-image-preloading-in.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;&lt;h3&gt;What is image preloading?&lt;/h3&gt;&lt;br /&gt;Image preloading is loading images into a browsers cache, before the user requests to see a certain image. By doing this, you avoid making the user wait those extra seconds to see the picture he/she wants to see.&lt;br /&gt;&lt;br /&gt;In effect, the images will be downloading in the background and saved in the users' cache. On one hand, the user will get to see the images as soon as he/she clicks the image, on the other hand you're making the user download all images, whilst they may not be wanting to see all the pictures, which means you've not only used up their bandwidth, but your own too. If you're on a tight budget, take into account that implementing this technique will make every single page load every single image of the folder the user has requested.&lt;br /&gt;&lt;br /&gt;And than there's the text files, which also get bigger, since you need to preload all those images.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;How do you do it?&lt;/h3&gt;&lt;br /&gt;The amount of code needed is very small.&lt;br /&gt;&lt;pre class="brush:js;wrap-lines:false"&gt;var preLoad = new Image();&lt;br /&gt;preLoad.scr = "URL/to/file";&lt;/pre&gt;&lt;br /&gt;Once you've done that, you're done. No need to put inline JavaScript in your HTML to switch sources and such. The reason for that is that by preloading, JavaScript will save the image to your cache. Upon next requesting it, your browser will first check the cache and find it there, and instantly display it on screen.&lt;br /&gt;&lt;br /&gt;The only hard part is that in pure JavaScript, removing an &amp;lt;img /&amp;gt; tag and creating a new one, with the correct attributes, can take up to 10 lines of code, for 1 image.&lt;br /&gt;I recommend using jQuery instead, which allows you to simple do this:&lt;pre class="brush:js;wrap-lines:false"&gt;$('#ID of whatever triggers the call for the next pic').click(function(){&lt;br /&gt;  var img = $('&amp;lt;img&amp;gt;').attr('src', '/link/to/correct/image/');&lt;br /&gt;  $('#ID of the element containing the img tag').html(img);&lt;br /&gt;});&lt;/pre&gt;&lt;br /&gt;Three lines of code, which can be used over and over to put a new pic in the same spot.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Trouble with multiple images&lt;/h3&gt;&lt;br /&gt;If you're going to be preloading multiple images, beware for 2 things:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The users' cache size limit. Very unlikely, but you never know.&lt;/li&gt;&lt;li&gt;Make a new Image() object for each image.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The 2&lt;sup&gt;nd&lt;/sup&gt; on is pretty important. Here's an example:&lt;br /&gt;&lt;pre class="brush:js;wrap-lines:false"&gt;var preLoading = ['image1.jpg','image2.jpg'];&lt;br /&gt;var image = new Image();&lt;br /&gt;for(var x = 0; x &lt; preLoading.length; x++){&lt;br /&gt;    image.src = preLoading[x];&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;If you use this implementation, only the last image in the array will be preloaded. You can see an implementation of that here:&lt;br /&gt;&lt;a href="http://www.rootspot.com/stackoverflow/preload.php" target="new" title="Implementation of using bad code to preload images"&gt;http://www.rootspot.com/stackoverflow/preload.php&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;When the site finished loading, click the second image. It will become visible immediately. However, the first image will have to be downloaded. It's a pretty big file, so no matter your connection speed, you should be getting this.&lt;br /&gt;&lt;br /&gt;The correct code is:&lt;pre class="brush:js;wrap-lines:false"&gt;var preLoading = ['image1.jpg','image2.jpg'];&lt;br /&gt;for(var x = 0; x &lt; preLoading.length; x++){&lt;br /&gt;    var image = new Image();&lt;br /&gt;    image.src = preLoading[x];&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;I have no example of it, but anyone with a bit of coding experience should see why this works.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Credits&lt;/h4&gt;&lt;br /&gt;Thanks to the guys at Stackoverflow who had already worked this out:&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/860910/how-does-the-javascript-preloading-work#answer-860929"&gt;Link 1&lt;/a&gt; and &lt;a href="http://stackoverflow.com/questions/761263/what-is-the-best-way-to-preload-multiple-images-in-javascript#answer-761280"&gt;Link 2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It looked interesting and I felt like making a blog about it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-2337539818783479226?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/2337539818783479226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=2337539818783479226&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/2337539818783479226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/2337539818783479226'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/06/efficient-image-preloading-in.html' title='Efficient image preloading in JavaScript'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-7721324438502419668</id><published>2009-05-21T00:30:00.020+02:00</published><updated>2010-03-20T03:33:01.018+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xhtml'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>XHTML versus HTML</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'XHTML versus HTML';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/05/xhtml-versus-html.html';&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;I recently set out to check HTML5 vs XHTML2 a bit.&lt;br /&gt;&lt;br /&gt;Here's a nice comparison: &lt;a href="http://xhtml.com/en/future/x-html-5-versus-xhtml-2/" target="new" title="XHTML 5 Versus XHTML 2 article"&gt;XHTML 5 Versus XHTML 2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It's a nice article, simply listing the new things about XHTML2 and HTML5. No opinions on which of the two is better.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;u&gt;Beginnings&lt;/u&gt;&lt;/h3&gt;&lt;br /&gt;When I first started studying web development, we were taught to use XHTML 1.0, later XHTML 1.1&lt;br /&gt;&lt;br /&gt;Our course gives a reason for this:&lt;blockquote&gt;Not picking a standard is not an option, unless you want to start coding in a manner that will put you out of a job in a few years. So HTML or XHTML? Since the step from HTML to XHTML is a small one, it's best to choose XHTML.&lt;/blockquote&gt;&lt;br /&gt;So we went for XHTML. And learning XHTML and comparing it with HTML4.01 tells me that XHTML is &lt;i&gt;cleaner&lt;/i&gt;. Every time I see attributes without quotes, I feel a little uncomfortable. Same for unclosed tags or tags with capital letters. I just liked XHTML and the strict rules if offered more than the easy going, not-caring-about-errors HTML I came across on the internet.&lt;br /&gt;&lt;br /&gt;The course in question was written in 2006. Today is 2009 and things have changed more than anyone could have thought possible 3 years ago.&lt;br /&gt;&lt;br /&gt;With Firefox 3.5 implementing the &amp;lt;audio&amp;gt; and &amp;lt;video&amp;gt; tags, IE finally mastering the ACID2 test with IE8 and Opera 10 almost arriving, the landscape of web browsers and the syntax of websites has taken a turn in a different direction.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;u&gt;The present&lt;/u&gt;&lt;/h3&gt;&lt;br /&gt;XHTML is no longer the future of web development. And as it turns out, it never was to begin with. Yes, too bad for XHTML&lt;a href="http://yoshiko-86.deviantart.com/art/sad-108728159" target="new"&gt;&lt;img src="http://fc05.deviantart.com/fs40/f/2009/007/c/1/sad_by_Yoshiko_86.gif" alt="sad" width="50" height="50" /&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Why was it never that, you may ask? Very simple: not a single browser has ever properly implemented it. You heard me: XHTML was &lt;b&gt;never&lt;/b&gt; properly implemented by the web browsers.&lt;br /&gt;&lt;br /&gt;You might be saying: "But I coded everything in XHTML and the W3C validator says it's fine and the site is displayed correctly".&lt;br /&gt;&lt;br /&gt;Well, that's all good and well, but your XHTML is being treated as if HTML. You see, XHTML is actually HTML + XML. Adding XML to HTML was supposed to bring flexibility and loads of powerful extra options to websites. So XHTML was born. Let's look at this next website shall we?&lt;br /&gt;&lt;a href="http://www.webdevout.net/articles/beware-of-xhtml-examples/2.xhtml" target="new" title="Fine example of XML plus HTML"&gt;HTML+MATHML+SVG&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Using XHTML, we added together HTML, MathML and SVG. Is it W3C valid? &lt;a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.webdevout.net%2Farticles%2Fbeware-of-xhtml-examples%2F2.xhtml&amp;charset=(detect+automatically)&amp;doctype=Inline&amp;group=0" target="new" title="Giving the previous site to the W3C validator"&gt;You bet ya!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Try pressing &lt;kbd title="Whilst viewing that page, hold down the CTRL button and then press the letter U"&gt;CTRL+U&lt;/kbd&gt;. You now have the source code of that page.&lt;br /&gt;Make a new HTML file, paste the sourcecode in there and try viewing it in your browser. You'll notice that you're not getting the same result.&lt;br /&gt;&lt;br /&gt;The reason for this is pretty simple: XHTML has to be interpreted, meaning that it has to be given to your web server, and the webserver must then give the proper information to your browser, in order to correctly display what you want to be shown.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;u&gt;Getting it to work&lt;/u&gt;&lt;/h2&gt;&lt;br /&gt;So in other words: you have to set up a server.&lt;br /&gt;I happen to have Apache 2.2.11 installed. So I went to the httpd.conf file and added this line of code, which is necessary:&lt;pre class="brush:shell;wrap-lines:false"&gt;AddType application/xhtml+xml .xhtml&lt;/pre&gt;.&lt;br /&gt;I saved the code to a file named test3.html under my htdocs folder, so I started my browser and entered this &lt;abbr title="Uniform Resource Locator"&gt;URL&lt;/abbr&gt;: &lt;pre class="code"&gt;http://localhost/test3.html&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;And you guessed it: &lt;b&gt;It works!&lt;/b&gt; (Yes, pun intended)&lt;br /&gt;&lt;br /&gt;Get the full article here: &lt;a href="http://www.webdevout.net/articles/beware-of-xhtml/" target="new" title="Beware of XHTML article"&gt;Beware of XHTML&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;u&gt;Conclusion&lt;/u&gt;&lt;/h3&gt;&lt;br /&gt;As a developer, you can't go without a server, so you'll probably have one.&lt;br /&gt;And in modern web development, there are so many apps to do fancy fonts and mathematical representations for you, that almost nobody uses MathML. SVG is a little more popular, but still insignificant in amounts.&lt;br /&gt;&lt;br /&gt;My conclusion is that for each task, you need different tools. Depending on what site you have to work on, you might come across things like this, and if you don't know how to handle it, the customer will simply go elsewhere with his/her money.&lt;br /&gt;Looking into this subject was pretty fun, since it helped me see that web development goes way beyond "HTML vs XHTML".&lt;br /&gt;&lt;br /&gt;So in the future, I'll be using HTML5 doctype whenever I can, and XHTML when needed. That seems like a good plan.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-7721324438502419668?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/7721324438502419668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=7721324438502419668&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7721324438502419668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7721324438502419668'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/05/xhtml-versus-html.html' title='XHTML versus HTML'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-1848372409942948812</id><published>2009-04-29T19:44:00.007+02:00</published><updated>2010-03-20T03:32:48.804+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='box model'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Absolute positioning within relative, the victory of the box model.</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Absolute positioning within relative';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/04/absolute-positioning-within-relative.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;I found this at Stackoverflow, whilst looking through posts on CSS.&lt;br /&gt;It shows how to use absolute positioning within relative positioning.&lt;br /&gt;&lt;br /&gt;The W3C describes the effect of &lt;pre class="brush:css;wrap-lines:false"&gt;position: absolute;&lt;/pre&gt; as:&lt;br /&gt;&lt;q&gt;An element with position: absolute is positioned at the specified coordinates relative to its containing block. The element's position is specified with the &amp;quot;left&amp;quot;, &amp;quot;top&amp;quot;, &amp;quot;right&amp;quot;, and &amp;quot;bottom&amp;quot; properties&lt;/q&gt;&lt;br /&gt;&lt;br /&gt;Let's focus on an important detail of that text: &lt;cite&gt;relative to its containing block&lt;/cite&gt;.&lt;br /&gt;&lt;br /&gt;This &amp;quot;block&amp;quot; is the &amp;quot;box&amp;quot; from the &amp;quot;box model&amp;quot;.&lt;br /&gt;So, let's look at some boxes:&lt;pre class="brush:html;wrap-lines:false"&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xml:lang=&amp;quot;en&amp;quot; lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=utf-8&amp;quot;/&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Boxy Boxes in a Box&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;style type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot;&amp;gt;&lt;br /&gt;    #container {position: relative; margin: 100px auto; height: 175px; width: 175px;}&lt;br /&gt;&lt;br /&gt;    .box {width: 35px; height: 35px; position: absolute; text-align: center; line-height: 35px;}&lt;br /&gt;&lt;br /&gt;    #box_1 {top: 0; left: 0; width: 140px; background-color: silver;}&lt;br /&gt;    #box_2 {top: 0; right: 0; height: 140px; background-color: maroon; line-height: 140px;}&lt;br /&gt;    #box_3 {top: 35px; left: 0; height: 140px; background-color: navy; line-height: 140px;}&lt;br /&gt;    #box_4 {top: 35px; left: 35px; width: 70px; background-color: red;}&lt;br /&gt;    #box_5 {top: 35px; right: 35px; height: 70px; background-color: blue; line-height: 70px;}&lt;br /&gt;    #box_6 {top: 70px; left: 35px; height: 70px; background-color: yellow; line-height: 70px;}&lt;br /&gt;    #box_7 {top: 70px; left: 70px; background-color: white;}&lt;br /&gt;    #box_8 {bottom: 35px; right: 35px; width: 70px; background-color: green;}&lt;br /&gt;    #box_9 {bottom: 0; right: 0; width: 140px; background-color: orange;}&lt;br /&gt;    &amp;lt;/style&amp;gt;&lt;br /&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;div id=&amp;quot;container&amp;quot;&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_1&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;1&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_2&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;2&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_3&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;3&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_4&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;4&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_5&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;5&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_6&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;6&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_7&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;7&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_8&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;8&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;div id=&amp;quot;box_9&amp;quot; class=&amp;quot;box&amp;quot;&amp;gt;9&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;Al you need to do is copy this, paste it into a fresh HTML document and view it in the browser.&lt;br /&gt;&lt;br /&gt;It's a pretty funny sight and show the power of the CSS boxmodel. Enjoy&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-1848372409942948812?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/1848372409942948812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=1848372409942948812&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/1848372409942948812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/1848372409942948812'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/04/absolute-positioning-within-relative.html' title='Absolute positioning within relative, the victory of the box model.'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-309979765730886921</id><published>2009-04-11T21:12:00.007+02:00</published><updated>2010-03-20T03:32:19.611+01:00</updated><title type='text'>Angry at Thumbs.db</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Angry at Thumbs.db'; &lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/04/angry-at-thumbsdb.html';   &lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;Something other than web development this time.&lt;br /&gt;&lt;br /&gt;Every now and then I find Thumbs.db files all over my hard drive. I find it rather annoying.&lt;br /&gt;&lt;br /&gt;Thumbs.db files are used by Windows to store thumbnails, which make sure that if you look at your folder containing your vacation pictures again, the thumbnails are loaded immediately instead of Windows having to generate them again and again.&lt;br /&gt;&lt;br /&gt;While this is useful for some people, for others it is not. My view settings are almost always on "details", meaning I don't need these thumbnails.&lt;br /&gt;&lt;br /&gt;There is a way to disable them, by selecting "do no cache thumbnails" in the folder view options. Being an ICT student though, that's not good enough for me.&lt;br /&gt;&lt;br /&gt;I once came across a BATCH command which claimed it would delete all Thumbs.db files on your drive. I tried it out and it appeared to work, but something tells me the original poster doesn't know what "hidden" files are.&lt;br /&gt;Many Thumbs.db files are in fact hidden. Hidden files can only be viewed when you select it in the settings.&lt;br /&gt;&lt;br /&gt;So I modified it a bit and here's the result:&lt;pre class="brush:bash;wrap-lines:false"&gt;del /s /q /f /a:h Thumbs.db&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, in steps:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Click start, click Run&lt;/li&gt;&lt;li&gt;enter the letters "cmd"(without the "") and press enter&lt;/li&gt;&lt;li&gt;The dosbox will appear, enter the command&lt;pre class="brush:bash;wrap-lines:false"&gt;cd \&lt;/pre&gt; and press enter. This will take you to the topmost map on your harddrive&lt;/li&gt;&lt;li&gt;Enter the above command and press enter. This will take a while, depending on how large your harddrive is.&lt;/li&gt;&lt;li&gt;If you have other drives you want to sweep like this, you can go to those by entering a command. Suppose the other drive is labeled E, type&lt;pre class="brush:bash;wrap-lines:false"&gt;e:&lt;/pre&gt; and press enter. You will have switched drives and now you can execute the command again.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;I posted this command on my Snipplr account too, you can find it here: &lt;a href="http://snipplr.com/view/13464/remove-all-thumbsdb-files/" target="new" title="link to a post on this subject on my Snipplr.com account"&gt;http://snipplr.com/view/13464/remove-all-thumbsdb-files/&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Hope this was helpful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-309979765730886921?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/309979765730886921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=309979765730886921&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/309979765730886921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/309979765730886921'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/04/angry-at-thumbsdb.html' title='Angry at Thumbs.db'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-7706349165602646972</id><published>2009-04-06T22:39:00.008+02:00</published><updated>2010-03-20T03:32:00.939+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='assembler'/><category scheme='http://www.blogger.com/atom/ns#' term='asm'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='goto'/><title type='text'>PHP and ASM (Assembler Language)</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'PHP and goto';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/04/php-and-asm-assembler-language.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;NOTE: what I'm about to write here is only possible for PHP 5.3 and up.&lt;br /&gt;&lt;br /&gt;I've mentioned before that I'm still a student and that means I'm learning new things.&lt;br /&gt;So I was browsing along the PHP documentation and I found something of which I wonder why it was implemented in the PHP language.&lt;br /&gt;&lt;br /&gt;For those of you who've programmed ASM in the past, this will look familiar.&lt;br /&gt;Pulled straight out of the online documentation:&lt;pre class="brush:php;wrap-lines:false"&gt;&amp;lt;?php&lt;br /&gt;goto a;&lt;br /&gt;echo 'Foo';&lt;br /&gt; &lt;br /&gt;a:&lt;br /&gt;echo 'Bar';&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The output will be &lt;pre style="display:inline"&gt;Bar&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;You can read the online documentation for this here: &lt;a href="http://be2.php.net/manual/en/control-structures.goto.php" target="new" title="A hyperlink to the online PHP documentation of the goto statement."&gt;http://be2.php.net/manual/en/control-structures.goto.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The moment I saw this, I was reminded of the 3 months I got some classes on ASM programming. Using loops and stuff, going back and forth between these declarations with these simple 'goto' statements.&lt;br /&gt;&lt;br /&gt;I came across a blog post from way back in 2004, when "adding goto to PHP" was apparently a discussion.&lt;br /&gt;Link: &lt;a href="http://www.procata.com/blog/archives/2004/07/29/goto-in-php/" target="new" title="Article about adding the goto statement to the PHP language"&gt;http://www.procata.com/blog/archives/2004/07/29/goto-in-php/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So, PHP is &lt;b&gt;adding&lt;/b&gt; this to the language... why?&lt;br /&gt;Almost the entire programming world agrees on the statement that "goto is dangerous".&lt;br /&gt;&lt;br /&gt;When I first saw this, I thought: "hey, this might make things easier in PHP-land."&lt;br /&gt;But after reading a few articles and thinking about it a bit, it will probably make things much, much harder most of the time.&lt;br /&gt;&lt;br /&gt;So I'm turning this post into a question: why did PHP bother to add this deprecated statement to the language?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-7706349165602646972?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/7706349165602646972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=7706349165602646972&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7706349165602646972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7706349165602646972'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/04/php-and-asm-assembler-language.html' title='PHP and ASM (Assembler Language)'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-5552664250567152746</id><published>2009-03-23T14:26:00.020+01:00</published><updated>2010-03-20T03:31:45.429+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Maps'/><title type='text'>The different ways of doing something</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Google Maps take 2'; &lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/03/different-ways-of-doing-something.html';   &lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;My previous blog was about Google Maps and how I implemented it.&lt;br /&gt;I did this the way the online documentation showed me how to do it: with pure JavaScript.&lt;br /&gt;&lt;br /&gt;A fellow student of mine, &lt;a href="http://lesterdoesblog.be/" title="link to Lester's blog" target="new"&gt;Lester&lt;/a&gt;, contacted me on how I implemented Google Maps and showed me how he did it.&lt;br /&gt;&lt;br /&gt;Apparently, he'd come across a PHP library that makes the work a lot easier. I've experimented with it a bit and it has some nifty features.&lt;br /&gt;&lt;br /&gt;You can view the source code here: &lt;a href="http://www.phpinsider.com/php/code/GoogleMapAPI/" target="new" title="Link to the phpInsider Google Map API"&gt;http://www.phpinsider.com/php/code/GoogleMapAPI/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And view a nice demo here: &lt;a href="http://www.phpinsider.com/php/code/GoogleMapAPI/demo/" target="new" title="Google Maps API demo"&gt;Demo&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;First, a non-coding related complaint: why is it only available as a tar.gz download?&lt;br /&gt;I don't work on Linux all that much (which I hope to change soon, but still), so a zip file would be nice.&lt;br /&gt;&lt;br /&gt;Now about the coding, it requires a minimal amount of php code. All you have to do is require the API, set your Google Maps key, and then you can start working. An example:&lt;br /&gt;&lt;pre class="brush:php;wrap-lines:false"&gt;$map-&gt;setAPIKey('my key');&lt;br /&gt;$map-&gt;addMarkerByAddress('Address 1','Name for address 1');&lt;br /&gt;$map-&gt;addMarkerByAddress('Address 2','Name for address 2');&lt;/pre&gt;&lt;br /&gt;You'll have to fill in a real key and real addresses offcourse.&lt;br /&gt;&lt;br /&gt;Not using a template here, so in your HTML, you'll find this:&lt;br /&gt;&lt;pre class="brush:php;wrap-lines:false"&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;?php $map-&amp;gt;printHeaderJS(); ?&amp;gt;&lt;br /&gt;  &amp;lt;?php $map-&amp;gt;printMapJS(); ?&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;/pre&gt;&lt;br /&gt;And to finally implement it:&lt;pre class="brush:php;wrap-lines:false"&gt;&amp;lt;body onload=&amp;quot;onLoad()&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;?php $map-&amp;gt;printMap(); ?&amp;gt;&lt;br /&gt;  &amp;lt;?php $map-&amp;gt;printSidebar(); ?&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;/pre&gt;&lt;br /&gt;And we have ourselves a working Google map.&lt;br /&gt;&lt;br /&gt;I did it a bit differently, I made a small .gif file to demonstrate how my own implementation works, you can view it here: &lt;a href="http://i637.photobucket.com/albums/uu91/Vordreller/my_maps.gif?t=1237817458" target="new" title="link to my gif file, showing how I implemented it"&gt;Link&lt;/a&gt;.&lt;br /&gt;As you can see, the scrollbar is at the bottom. When I click the link above the map, the route description between the 2 addresses shows up.&lt;br /&gt;&lt;br /&gt;What I miss in the API is the ability to plan a route between 2 points. I can't tell it to make a route, like I did in my implementation.&lt;br /&gt;&lt;br /&gt;Also, this API has a function to calculate the distance between 2 points. It does so by using the geocoordinates of those points. In other words, the calculated distance will be in a straight line from point A to point B. It's related to &lt;a href="http://en.wikipedia.org/wiki/Spherical_geometry" target="new" title="Wikipedia article on spherical geometry"&gt;this&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Personally, I would prefer to know the distance I have to drive or walk from point A to point B instead of how far it is in a straight line.&lt;br /&gt;&lt;br /&gt;But other than that, it's a nifty little library.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-5552664250567152746?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/5552664250567152746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=5552664250567152746&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/5552664250567152746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/5552664250567152746'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/03/different-ways-of-doing-something.html' title='The different ways of doing something'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-6726742205001662548</id><published>2009-03-13T13:19:00.016+01:00</published><updated>2010-03-20T03:31:36.274+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Maps'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Learning to use google maps</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Learning to use google maps';&lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/03/learning-to-use-google-maps.html';&lt;br /&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;Today, I programmed something in Google Maps for the first time.&lt;br /&gt;I pulled out a few hairs and all that, but it all worked in the end.&lt;br /&gt;&lt;br /&gt;What I have on my hands is a site where it is mandatory to enter your address.&lt;br /&gt;So when you're viewing someone's profile, a Google Map appears and you immediately see a route on the map from your place to theirs. I do this via PHP, the profile address pulled from the database and the address of the viewing person from a cookie.&lt;br /&gt;&lt;br /&gt;The code I ended up with is a bit different from the example code you'll find on the documentation pages, but I find it to be shorter and much more to the point.&lt;br /&gt;&lt;br /&gt;I'm posting it here so others can learn from it and I have a place to post it and can come back to look at it should I ever need it or Google Maps in general again.&lt;br /&gt;&lt;br /&gt;Note that the XHTML version is 1.1, which is why I'm using CDATA tags.&lt;br /&gt;&lt;br /&gt;I put this directly in my HTML, in the head block.&lt;br /&gt;&lt;pre class="brush:js;wrap-lines:false"&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt; //&amp;lt;![CDATA[&lt;br /&gt; var map; &lt;br /&gt; var directionsPanel;&lt;br /&gt; var directions;&lt;br /&gt;&lt;br /&gt; function initialize(address1,address2) {&lt;br /&gt;   if (GBrowserIsCompatible()) {&lt;br /&gt;     map = new GMap2(document.getElementById("map"));&lt;br /&gt;     //that slider zoom thingy&lt;br /&gt;     map.addControl(new GLargeMapControl());&lt;br /&gt;     //a scale, showing the actuall distance&lt;br /&gt;     map.addControl(new GScaleControl());&lt;br /&gt;     //allows you to choose between normal map, sattelite...&lt;br /&gt;     map.addControl(new GMapTypeControl());&lt;br /&gt;&lt;br /&gt;     //the route description &lt;br /&gt;     directionsPanel = document.getElementById("route");&lt;br /&gt;     directions = new GDirections(map, directionsPanel);&lt;br /&gt;     directions.load("from: "+address1+" to: "+address2);&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;//]]&amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And then somewhere in your XHTML document you'll need these:&lt;br /&gt;&lt;pre class="brush:html;wrap-lines:false"&gt;&amp;lt;span&amp;gt;Google map:&amp;lt;a href=&amp;quot;#&amp;quot; id=&amp;quot;showroute&amp;quot;&amp;gt;Click for route description.&amp;lt;/a&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;&amp;lt;div id=&amp;quot;map&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;div id=&amp;quot;route&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;What'll happen is the div with ID "map" will be used to contain the actual map and the div with ID "route" will get the route description.&lt;br /&gt;I used a separate CSS document to make sure it's not displayed automatically.&lt;br /&gt;&lt;br /&gt;Then I made a little JavaScript document to display the route description upon clicking that anchor:&lt;br /&gt;&lt;pre class="brush:js;wrap-lines:false"&gt;function loadEvents() {&lt;br /&gt;  var toon = document.getElementById('showroute');&lt;br /&gt;  var route = document.getElementById('route');&lt;br /&gt;  toon.onclick = function() {&lt;br /&gt;    route.style.display = 'block';&lt;br /&gt;    return false;&lt;br /&gt;  };&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That's the code, now to get it all to work, I simply wrote this at the bottom of the XHTML page:&lt;br /&gt;&lt;pre class="brush:js;wrap-lines:false"&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;if(document.getElementById) {&lt;br /&gt;  initialize({ADDRESS1},{ADDRESS2});&lt;br /&gt;  loadEvents();&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And that's what made it work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-6726742205001662548?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/6726742205001662548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=6726742205001662548&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/6726742205001662548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/6726742205001662548'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/03/learning-to-use-google-maps.html' title='Learning to use google maps'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-4962410276462783929</id><published>2009-03-08T23:25:00.014+01:00</published><updated>2010-03-20T03:31:26.018+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='minify css'/><category scheme='http://www.blogger.com/atom/ns#' term='minify code'/><title type='text'>Minifying CSS</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Minifying CSS'; &lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/03/minifying-css.html';&lt;/script&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;&lt;span style="font-family:verdana;"&gt;I announced it in my previous post: &lt;a href="http://webdevhobo.blogspot.com/2009/03/minifying-code.html" target="new" title="My blog post about minifying code in relation to bandwith issues."&gt;Minifying code&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So here it is, a summarization of my CSS code minifying tricks.&lt;br /&gt;Please note that you should not make your code unreadable while editing it. It's probably best to have a separate development environment apart from the servers where your code is actually downloaded from. That way you can work on a normal location and when you're done, you minimize your code and transfer that file to the actual server.&lt;br /&gt;&lt;br /&gt;So here are some tricks I use:&lt;/span&gt;&lt;hr /&gt;&lt;h2 style="font-weight: bold;"&gt;Color code&lt;/h2&gt;A web browser can interpret the values you give to color declarations in many ways.&lt;br /&gt;For instance:&lt;br /&gt;&lt;pre class="brush:css;wrap-lines:false"&gt;color: #44FF66&lt;/pre&gt;Can be turned into&lt;pre class="brush:css;wrap-lines:false"&gt;color:#4F6&lt;/pre&gt;And it's limited to that. You can't turn &lt;pre class="brush:css;wrap-lines:false"&gt;color: #44F2F2&lt;/pre&gt;Into&lt;pre class="brush:css;wrap-lines:false"&gt;color: #4F2F2&lt;/pre&gt;It needs to be either 3 or 6 numbers.&lt;br /&gt;&lt;br /&gt;&lt;h2 style="font-weight: bold;"&gt;The last semicolon&lt;/h2&gt;The last semicolon in a CSS code block is not needed.&lt;br /&gt;Example:&lt;pre class="brush:css;wrap-lines:false"&gt;h5 {&lt;br /&gt;padding: 5px;&lt;br /&gt;border: solid 1px blue;&lt;br /&gt;line-height: 20px;&lt;br /&gt;color: green&lt;br /&gt;}&lt;/pre&gt;Notice how the color declaration has no ; symbol after it. That's because it's not needed. The reason for that is that it's the last declaration within that code block. Also, if there's only 1 declaration in a block, then it doesn't need a semicolon.&lt;br /&gt;&lt;br /&gt;&lt;h2 style="font-weight: bold;"&gt;Putting sub-attributes together&lt;/h2&gt;I've done this already in the piece of CSS code right above this topic:&lt;pre class="brush:css;wrap-lines:false"&gt;border: solid 1px blue&lt;/pre&gt;What I've done here is taking a few sub-attributes of the border property and put them together.&lt;br /&gt;What would normally take 3 lines of code:&lt;pre class="brush:css;wrap-lines:false"&gt;border: solid;&lt;br /&gt;border-color: blue;&lt;br /&gt;border-width: 1px&lt;/pre&gt;And turned it into a single line:&lt;pre class="brush:css;wrap-lines:false"&gt;border: solid 1px blue&lt;/pre&gt;The order is of no importance here. I could just as well put "solid" after "blue". You can even write&lt;pre class="brush:css;wrap-lines:false"&gt;border: blue;&lt;/pre&gt;Instead of&lt;pre class="brush:css;wrap-lines:false"&gt;border-color:blue;&lt;/pre&gt; You can do this with all attributes that have sub-attributes I think. I don't know all of them, but the background attribute is another example of putting sub-attributes together.&lt;br /&gt;&lt;br /&gt;&lt;h2 style="font-weight: bold;"&gt;Margin and Padding(and border too)&lt;/h2&gt;When declaring how many pixels, points or em values your padding, margin or border is, you can use the "shorthand" notation to save on keystrokes. Be careful, if you do this with borders, then you won't be able apply the sub-attribute trick anymore. You'll have to enter every value separatly.&lt;br /&gt;&lt;br /&gt;Here's something I see often:&lt;pre class="brush:css;wrap-lines:false"&gt;margin: 40px 40px 40px 40px&lt;/pre&gt;This is a waste of space. You're saying all 4 directions are to be given 40 pixels, which doesn't require that amount of code at all.&lt;br /&gt;It can be done with:&lt;pre class="brush:css;wrap-lines:false"&gt;margin: 40px&lt;/pre&gt;This is saying all 4 directions are to receive that amount.&lt;br /&gt;&lt;br /&gt;That long notation declaring a distance 4 times works as follows:&lt;pre class="brush:css;wrap-lines:false"&gt;MARGIN: TOP RIGHT BOTTOM LEFT&lt;/pre&gt;How do I remember? It's the same way clocks rotate. At 12, the long arrow points to the top, as it turns it'll point right, then to the bottom and then to the left.&lt;br /&gt;&lt;br /&gt;You can also do this:&lt;pre class="brush:css;wrap-lines:false"&gt;border-width: 8px 5px 2px&lt;/pre&gt;This is: TOP, RIGHT and LEFT, BOTTOM.&lt;br /&gt;&lt;br /&gt;And finally, there's this:&lt;pre class="brush:css;wrap-lines:false"&gt;margin: 15px 2px;&lt;/pre&gt;This is: TOP and BOTTOM, LEFT and RIGHT.&lt;br /&gt;&lt;hr /&gt;That's it for me. See any errors or know some tricks I don't? Feel free to let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-4962410276462783929?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/4962410276462783929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=4962410276462783929&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/4962410276462783929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/4962410276462783929'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/03/minifying-css.html' title='Minifying CSS'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-7476113585660513478</id><published>2009-03-08T22:44:00.016+01:00</published><updated>2010-03-20T03:30:40.525+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='minify javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='minify css'/><category scheme='http://www.blogger.com/atom/ns#' term='minify code'/><category scheme='http://www.blogger.com/atom/ns#' term='bandwidth issues'/><title type='text'>Minifying code</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;    social_prefix = 'RT @Vordreller';&lt;br /&gt;    social_title = 'Minifying code'; &lt;br /&gt;    social_url = 'http://webdevhobo.blogspot.com/2009/03/minifying-code.html';&lt;br /&gt;&lt;/script&gt;&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;script type="text/javascript" src="http://widget.social.com/widgets/button1.js?wid=1&amp;pid=1269051877111472&amp;bl=&amp;bsnc=&amp;bsnbac=&amp;bshc=&amp;bshbac=&amp;bsnboc=&amp;ff=0"&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;To put their website online, people will usually apply for online web space. Up to a certain amount of megabytes, this is usually free. When you pass that amount, you have to pay real money for it. But you also have to pay for used bandwidth.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Now, for those of you who don't know what bandwidth is, I'll just say it's a measure for the amount of data your server(s) have received and have sent. This is usually monitored monthly.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Let's say you can afford 1000 dollar per month. Nice round number.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Let's say that gets you 4 Terabytes per month. Just picking a random number, I realize it's probably not very realistic.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Now for the past couple of months, you've seen the used bandwidth per month go for that 4 TB and now suddenly, your worst nightmares come true: your site has used more than the 4 TB you pay for.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;For those who have no experience with this: 4 TB of data per month is a decent amount, a &lt;b&gt;very&lt;/b&gt; decent amount.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;So how does this involve web development? It's as follows:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I've already explained how bandwidth is measured by how much data is sent from and to server(s). This includes the files web browser needs to display your site.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;These files are usually, but not limited to, HTML files, CSS files and JavaScript files.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;You type in a URL, your browser send the request and the server that has those pages will receive it, read it and send you the pages you need. These pages have a certain size, usually several megabytes if your site is content-heavy.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;So that adds to your bandwidth. And you want to keep that bandwidth usage as low as possible.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;So in other words, you want to shrink the file size of those files.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The size of any text file is determined by the amount of characters in it. This is everything in it. Spaces, end of line statements, newlines, literally everything.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Here's a CSS example:&lt;/span&gt;&lt;br /&gt;&lt;pre class="brush:css;wrap-lines:false"&gt;* {&lt;br /&gt; font-family: Verdana, Arial, sans-serif;&lt;br /&gt; margin: 0px;&lt;br /&gt; padding: 0px;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This is some nice, readable css, perfect for editing while you're working on your website.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I'm counting the following:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;5 spaces&lt;/li&gt;&lt;li&gt;4 newlines&lt;/li&gt;&lt;li&gt;3 tabs&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Question: Does the browser need these to properly interpret the code?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Answer: No.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Conclusion: Waste of bandwidth!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;You might be saying: "who cares about a couple of spaces, some newlines and a few tabs"? The answer is, very few people do, but a lot of people (developers and owners of sites that get loads of traffic) should.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Here's the minified code:&lt;/span&gt;&lt;br /&gt;&lt;pre class="brush:css;wrap-lines:false"&gt;*{font-family:Verdana,Arial,sans-serif;margin:0;padding:0}&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Difference? 22 bytes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Big sites have big files, so this small piece of CSS code is less than 1％ of a real file for a site that goes over 4 TB.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;You don't need to be a math genius to realize that the saving on bandwidth can be very significant if you practice minimizing your code. Not only for CSS, but for your JavaScript too, and for all other text files. You might even go as far as stripping metadata of pictures displayed on your site. It all depends on how far you're willing to go.&lt;br /&gt;&lt;br /&gt;For those of you who are wondering how, check this lifehacker post: &lt;a href="http://lifehacker.com/5149327/jpeg--png-stripper-removes-the-metadata-from-your-images"&gt;http://lifehacker.com/5149327/jpeg--png-stripper-removes-the-metadata-from-your-images&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I realize this has been a long post, so I'll make a list of CSS minimizing tricks I know in the next post.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-7476113585660513478?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/7476113585660513478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=7476113585660513478&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7476113585660513478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/7476113585660513478'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/03/minifying-code.html' title='Minifying code'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7264343268942025532.post-2810559339627491768</id><published>2009-03-08T22:01:00.001+01:00</published><updated>2009-03-27T22:03:42.394+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='first'/><title type='text'>First post</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;Hooray, my first post.&lt;br /&gt;&lt;br /&gt;I've decided to keep this blog here as a sort of way to post about stuf that probably nobody will read. :P&lt;br /&gt;I'll be posting about webdevelopment, mostly the coding in (X)HTML, CSS, Javascript, PHP and other related stuff.&lt;br /&gt;&lt;br /&gt;And please note that Webdevelopment ≠ Webdesign. Webdesign is thinking about and creating the looks of a site. It's usually done in Photoshop or GIMP.&lt;br /&gt;Webdevelopment is the coding that makes a website actually work.&lt;br /&gt;&lt;br /&gt;And in general, designers are lousy developpers and developpers are lousy designers.&lt;br /&gt;People who are good at both are usually called "diviners".&lt;br /&gt;&lt;br /&gt;Sometimes my posts will be informative, other times it'll be ranting about stuff that gets on my nerves(regarding web developpement).&lt;br /&gt;&lt;br /&gt;Please note that my native language is not english, it's dutch. Still, I like to think my english is pretty good and since the web is mostly english, I'll be using english to blog here.&lt;br /&gt;&lt;br /&gt;Somuch for introductions, let's try making a second post about something actually usefull. And when I say usefull, I don't necessarily mean to web specialists. I am no specialist, I am a student. I'll be writing about the stuff I come across in my projects and on sites I visit and about my research.&lt;br /&gt;&lt;br /&gt;So you might think I'm posting about things that are childishly simply, but you might just be a developper with decades of experience. Students reading this might find stuff usefull that you allready know, and I'm not gonna spend time limiting myself like that.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7264343268942025532-2810559339627491768?l=webdevhobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://webdevhobo.blogspot.com/feeds/2810559339627491768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7264343268942025532&amp;postID=2810559339627491768&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/2810559339627491768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7264343268942025532/posts/default/2810559339627491768'/><link rel='alternate' type='text/html' href='http://webdevhobo.blogspot.com/2009/03/first-post.html' title='First post'/><author><name>WebDevHobo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
