Cover image for post FrOSCon "PHP best practices" slides online

FrOSCon "PHP best practices" slides online

Kore and me held our talk about "PHP best practices" this morning at the Free and Open Source software Conference and were quite successful, AFAICT. There were about 50 attendees, which listened concentrated over the whole time. The talk contains an overview on how to behave when coding PHP in respect to

  • General guidelines

  • Security

  • Performance

and gives a general overview on useful tools around PHP development.

You can find the slides in the talks section.

Correction, June 30th 2006: Ok, the guys from my usergroup convinced me to correct this. There were about 100 attendees in the talk, not only 50. :)


You wrote in there: "allways use ++$i instead of $i++" (in for loops). Why is that?

Wim H. at 2006-06-25

Oh, the wording was incorrect here. I rephrased it to "Where possible use...". Surely it is not allways possible, since post- and pre-increment operators are still semantically different. Anyway, there are tons of places, where ++$i is as appropriate as $i++ and the first one is simply much faster in PHP.

Thanks for the hint!

Toby at 2006-06-25

Interesting. I'd have thought that two so nearly identical functions would be nearly identical in speed as well. But the difference is indeed significant and in such a for loop, I can't think of any (other) reason to prefer one over the other.

In my quick benchmark (PHP 5.1.4 on Debian Linux) an (empty) for loop with ++$i was 11% faster than one with $i++.

Wim H. at 2006-06-26

Yeah, that is what we gathered also.

Toby at 2006-06-26