I’ve previous been writing about why PHP and Unicode/UTF-8 is a bad combination. Even though UTF-8 in PHP should (for now) be avoided, it is sometimes a necessity to use it. As UTF-8 can be quite problematic for some people to use, I thought I this time should write about how to actually use it properly. In this first part I’ll deal with the basic handling of UTF-8 in PHP using the PHP extensions mbstring and/or iconv.
Archive for the Category » PHP «
I’ve previously been talking about premature optimization. Today I thought I should illustrate how ridicules some of the stuff is by busting “echo is faster than print”. There’s a lot of people calming that this is true (1, 2, 3, 4 and a lot of others). Now to be clear, they are somewhat right about this. Echo is really faster than print, which it really should due to the fact that echo don’t return anything while print does. The problem and my point here however, is how much this difference really is. The answer is so tiny that you can forget actually measuring it in a real world application. There’s why: more…
Donald Knuth once wrote that “premature optimization is the root of all evil”. I have to agree with him on that. One thing I’ve been dying to write about is the massive amount of crappy PHP optimization tips found on the net. Two examples of such is Reinhold Weber’s 40 Tips for optimizing your php code and chazzuka’s 63+ best practice to optimize PHP code performances. They do both have some good tips here and there, but in general this is just stupid tips, or more precise, premature optimization. There are reasons why such tips are bad. more…
No, I’m not joking. As of last Saturday, the development team of PHP decided that backslash will be the new namespace separator in PHP, replacing :: which has been used up until now. The reason for this is quite alarming to be honest. A bug. more…
One thing that really annoy me these days is the unrestricted enthusiasm for PHP and Unicode, primarily in the form of UTF-8. These people seem to think that Unicode is some fantastic thing they just have to use even though a single byte charset like ISO-8859-1 is more than sufficient for their need. Don’t get me wrong, Unicode is good and everything, but not when you’re using PHP. Why? Because PHP by itself does not support Unicode. Now I know alot of people will object and say that there is mbstring. If you’re one of them, please read this carefully: mbstring is a Swiss cheese. Now I know alot of people is not using mbstring and basicly is using Unicode (most likely UTF-8) blissfully unaware of it’s dangers. So before I get into why mbstring is a horrible piece of coding, I’d like to explain why you shouldn’t use Unicode without some measures. more…

Recent Comments