Archive - Jun 19, 2007

I just changed hosting

in

I just changed hosting from NitroZone to Sveit after 3 and half month of great relationship. Sveit is offering me 3 months temporary hosting for free. Thx Sveit!
NitroZone is by far the best hosting I had, sadly it can't handle the coolest Asian in the world's CPU usage. I never knew Drupal is such a CPU killer. If you need a (very) cheap PHP4 hosting NitroZone can be a choice.

Internationalization with SimpleXML?

Jim Plush once published an article about externalized PHP strings performance for Internationalization and conclude SQLite is a great choice. He also said SimpleXML is the fastest out of other 2 methods--store as PHP native array and parse ini. He was right about the parsing speed.

The structure of the PHP native array

$msg[$key] = $var;

The structure of the XML file

<strings>
<string key="$key">$var</string>
</strings>

I did a small experiment with the same structure.

SimpleXML is fast. It's faster than PHP parse a native array, and it allocates less memory in both PHP process and system than the native array.

Sadly, it is just not possible for SimpleXML to work for internationalization, certainly not in the structure described above.

SimpleXML returns object in a tree form, and the key to each node of the tree is the tag name, not the attribute.
In the above case, the attribute stores the key. The only way to extract the key is to loop though and find the key. Clearly it's not a good idea. Even with SimpleXML's native xpath

$tmp = $lang->xpath('//p[@key=\'thekey\'');

Find the right string is a much more CPU intensive job than the native PHP array.

What if the structure of XML look like this?

<strings>
<$key>$var</$key>
</strings>

Answer is still no. With different tag names, loading the a XML file (100000 tags) took a jaw dropping 37 seconds.

Guess XML can be ruled out from language translation storage for PHP.

ask for help

Could anyone help me ask for help?

— Mgccl

Notes for June 19

in

A smart comedian will review his jokes once in a while and add something new...

I did some extension on the "Chinese people have numbers in their blood" joke, so I can go off tangent to link with other topics.
Chinese people actually stops all the vampires by turning them into mathematicians.
Yes, gay men are at risk in China
After reading that article, I totally understand. It's because of mathematical discrimination.
because Chinese don't forgive mathematically when gays get the the signs wrong.
people dies every year because they accidentally divide a number by zero.

shedding cells.

What makes skin soft? a scientific question...

Honey Pot that kill bots