Maarten Balliauw {blog}

Web development, NuGet, Microsoft Azure, PHP, ...


Simple SAX parser for PHP

Yesterday, I was working on PRAjax. The UpdatePanel did not work completely as I wanted it to work: in the background, the whole page was still fetched and updated. A cleaner way would be to just fetch updated content and not the whole page.

In my search for a PHP HTML parsing class, I found a lot of libraries, but all with disadvantages: one was too big in file size, another only parsed XHTML, ... Luckily, I stumbled on SAX parser! So if you ever want to parse HTML and read out specific tags and attributes, try this one.

Internet Explorer 7 RC1 available

When I opened my RSS reader this morning, I saw good news: Internet Explorer 7 RC1 has just been released! You can download it here or install it as stand-alone version (unofficial!).

Many people will like the new UI features, like tabbed browsing, tab preview, easier interface, less toolbars, ... The features I like are the better CSS support and other tech enhancements. For example, this blog uses several IE-specific CSS hacks to get everything (almost) in place. Now let's hope IE7 does not get confused by those hacks.

But I fear too: my PRAjax project relies on several browser specific objects, like XMLHttpRequest. I had to make some adaptations for IE7 beta 1, some adaptations for IE7 beta 2, so now I hope everything keeps working like a charm on IE7 RC1...

For those who tried beta 1 a while ago: the most annoying "feature" of IE7 has already been removed: if a page takes longer than 30 seconds to load, it keeps loading... In beta 1, it gave up saying the page was not available (really handy when you are debugging an ASP.NET web application Yell). Luckily, that's not longer an issue.

Google Analytics open for everyone!

Almost a year ago, Google acquired Urchin, a company specialised in providing web site statistics. They renamed Urchin's project to Google Analytics and started a beta for some. Today, it seems Google has opened Analytics for everyone. Get it while it's hot, they really provide in-depth statistics about what's happening on your website.

I tried it out for a few days on my website, and experienced all possibilities. Currently, I use Statcounter there, which also provides detailed statistics, but only for the last 100 visits.

One of the nice things on GA is that you can specify up to four goals for your website. A goal can be a user registration, an order, ... GA then tracks how many of your visitors reach one of those goals, and provides you with a conversion percentage. This can be handy to improve your website for better conversion.

Also, there are three different report views: Executive, Marketer and Webmaster, all showing statistics from a different angle. A webmaster might be interested in which browsers are visiting, an executive might benefit to know the conversion percentage.

Anyway, I'm keeping GA on Holidayhome and my blog, it provides in-depth stats and clear reporting.

JavaScript URI parameter encoding

When creating a HTTP request in JavaScript, I always used encode() and decode() to pass data between client and server. I also used this approach in PRAjax, my open-source Ajax helper library for PHP.

A developer working with PRAjax on his site reported to me last week that Swedish characters like å, ä, ö, ... were not passed corerctly to and from the server.

My first reaction was: add a UTF-8 header on the server side, and it should work. Characters from other character sets are always displayed correctly when doing that. Except when using JavaScript, it seemed when I tried entering Swedish...

After stepping through my code, I saw everything went wrong after I did encode() on my JavaScript variable. After an hour of different Google searches in the wrong direction, I found out that when using encodeURIComponent() instead of encode(), everything worked fine. It seems like encodeURIComponent() translates more characters than encode().

Goggles, a flight sim on Google Maps

You have probably already seen over a hundred uses for Google Maps. Today, I received a link of a new use: Goggles. Goggles allows you to fly a plane over a city, to climb and descent, to shoot at the scenery (I tried this over Amsterdam but didn't hear anything on the news. It's safe!). You even can crash.

A while ago I thought on developing a game on Google Maps too. No action-game, no flight simulator, but more a strategic game. Imagine a sort of Risk or Transport Tycoon on satellite imagery. Unfortunately, I didn't find the time to even think about a nice game concept. Maybe once!


I regularly drink a glass of beer (I prefer the Belgian Trappists) or a glass of wine. While surfing, I stumbled upon a handy link for all Belgian people who love to drink wine too: Kurkdroog

Kurkdroog is a website that acts as a hitlist of wines. You can select a price class, a supermarket, a country and a wine type (red, white, rosé, ...), and the site returns a list of wines matching your criteria, with the price and a short review next to it. Perfect stuff!

Age of Pirates

A few weeks ago, I discovered a nice online multi-player game: Age of Pirates. AoP is in a certain way similar to one of my favourite games Age of Empires, available as an offline game. In AoP, you have an island on which you have to gather resources in order to improve your economy and military activity.

When you have a certain grade, it's possible to create ships and to colonize other islands. There, you can crop cacao, hemp and other goods which you can trade with other players for money. Also, you can attack other player's islands and plunder their resources. And if your fleet is large enough, you can even takeover the island and incorporate it in your empire.

Anyway, the graphics and gameplay are very nice for a browser-based online game. The only disadvantage is that some translations are unfinished (a lot of German phrases in it, Capitän :-)). Another disadvantage is that you have to build an enormous economy prior to being able to build ships. But hey, it keeps me playing!


Today, I noticed that Phalanger has released a new beta a few days ago (well OK, half a month ago [*-)]). Phalanger is an open-source project, aiming to provide tools to integrate PHP development in Visual Studio on one side, and aiming to provide a CLR compiler for PHP on the other side.

In short, this means that Phalanger compiles PHP code to MSIL (Microsoft Intermediate Language) and thus can run PHP on the .NET Framework. I guess that would mean a huge PHP speed improvement!

Also, Phalanger provides access to native .NET namespaces, which can be used within PHP scripts. Nice! Imagine ASP.NET webcontrols and PHP code... For me, it sounds like a nice dream [Y].

I guess I'll have to check that all out. It's placed on my to-do list, which seems to always get filled more and more...

Have you alreday tried PRAjax?

Some people who know me, have already experimented with my home-brew PHP Ajax framework, PRAjax. PRAjax is short for PHP Reflected Ajax, and provides the glue between server-side PHP and client-side Javascript. You should really try it out in your project!

My blog uses PRAjax too. Try navigating to the homepage and clicking a [more...] link. The article body is then fetched behind the scenes and updated on your browser view.

A small example...

One can write a method in PHP, and make it callable by the client using JavaScript. For example, you have the following PHP code:

function Hello($pName = '') {
return 'Hello, ' . $pName;

On the client-side, you can now call this method asynchronously (using, for example, a link with an onclick method "Hello('Maarten');", and get the result in a callback function:

function Hello_cb (pData) {
if (pData != null) {

That's all there is to it! It's even possible to pass objects between PHP and JavaScript.

Currently, I'm considering porting this to ASP.NET but I do not expect much interest because of Atlas, which offers much more options combined with a complete ASP.NET-alike object model.

A new computer...

2 weeks ago, my previous computer died. A black screen with a white blinking cursor was the only thing it still did. Curious about that, I opened the case and saw... leaking capacitors. According to Google searches about that, something went wrong with industrial espionage a few years ago. Nice, I had spied capacitors and a dead computer. Even more typical was the fact that my warranty had expired 2 years ago. And that all in a week I planned to develop on my blog and some other private projects. The best cure to quicly get to work: a new computer.

So I went to my local computer store and ordered some new parts (motherboard, CPU, memory and a new graphics card). One week later, everithing arrived and I screwed everything in my computer case. Everything worked, I installed Windows and all other software, and decided to have a look at the internal temperatures... 71 degrees Celcius!!! Good to know that a Pentium D 915 gets hot when you have not enough ventilation in your case...

After buying 5 new coolers (2 for HD's, one front case fan, one rear case fan and a blower on the bottom) and installing them, my new PC adventure was not over... It didn't boot anymore!

Weird... Installing fans using just a bit of current influenced my computer. Anyway, I decided to take out all parts and re-install them, and see when it would't boot anymore. That way, I would know which part was defect. Very nice: I only kept my motherboard, cpu, memory and graphics card, plus the CDROM drives. No booting...

I tried plugging in the power connectors in my HD's one by one. DON'T TRY THIS AT HOME! I did, and one hard drive caught fire... Quickly pulling off the current and pulling out the HD (luckily, I didn't screw anything into place yet), didn't prevent the hard drive from dying too. Byebye, 120 GB's of storage...

3 hours later, I found out the ATA cable to my CDROM drive had died too. After replacing that, my computer worked again. Temperatures are better now, too. Everything except the CPU is below 30 degrees.

Conclusion: if you are trouble-shooting your hardware, make sure all cables work correctly...