PHP: The Dark Magic of Optimization

Changing a few characters in the source code and the script runs 600× faster. You just need to know when PHP silently duplicates a huge array behind your back – and why references and refcount inside zval structures are to blame. No black magic, just white.

HTTP Redirection

Extremely long numbers, meaning those with more than one digit, I simply can't remember. So I wrote myself a cheat sheet: what HTTP codes 300–307 mean, when to use which one, and why 302 is the black sheep that everyone loves and nobody respects.

The magic with conditional comments

Everyone knows that downlevel-revealed conditional comments are invalid. Everyone is wrong – all it takes is cleverly breaking and reopening an HTML comment in the right places. A few extra characters and you have a fully valid markup that IE ignores and other browsers see.

How to correctly insert a Flash into XHTML

Macromedia advises you to embed Flash in a way that is invalid, proprietary, and unable to display an alternative for the 10% of users without the plugin. After a series of dead ends, I found the only truly working solution – two objects separated by conditional comments. It's not elegant, but it works.

Such a Nomination is a Really Nice Thing

The Texy! nomination in the Czech Open Source 2006 competition brought me one thing above all: a collection of insults from people who have never created anything. Here's a showcase of them – and the reason why you feel like telling the entire open-source community to fuck off and just create in English.

Property setters and getters – final solution

Are PHP's magic __get() and __set() frustrating you? Same here. That's why I came up with a trick inspired by Delphi – public properties with accessor methods, no switches, with phpDoc support and protection of private members. An elegant hack for the time when PHP didn't yet support properties.

PHP 5 → 4 converter

Sometimes progress means going backward. I created a converter that rewrites PHP 5 OOP constructs – abstract classes, interfaces, access modifiers, exceptions, and more – into equivalents that work in PHP 4. You can try it out live right away.

How to emulate PHP5 object model in PHP4

Remember when PHP4 copied objects like a paranoid librarian making backups? I built a tiny compatibility layer that tricks PHP4 into behaving like PHP5 — just extend one class and let references do the dirty work. Good programmers declare their variables anyway, right?

Texy! and it's out!

Texy! has become the Godot of the Czech web – everyone was waiting, nobody had seen it, and yet a small cult formed around it. The beta is officially out under a dual GPL/commercial license, and I'm looking for brave testers and translators willing to work for eternal glory.

Texy! is Sexy!

The most complex text formatter I know – typography, tables, CSS, valid code, and Czech national specifics including non-breaking spaces after prepositions. Is it incompatible with anything else? Sure. But why be compatible when you're better?

That's all. More articles are on the way.

phpFashion © 2004, 2026 David Grudl | o blogu

Ukázky zdrojových kódů smíte používat s uvedením autora a URL tohoto webu bez dalších omezení.