The little bugger, a result of being overly clever, cost me an hour of debugging. Don't repeat my mistakes, clear your loops!Continue reading "Be wary of reference loops in PHP"
Every now an then the need for fine-grained whitespace control pops up in the smarty forums. While Smarty itself doesn't offer whitespace control functionality, we can easily implement it ourselves.Continue reading "Smarty - Whitespace Control"
For the release of Smarty 3.1.0 I refactored most of Smarty's disk access. As this optimization from September 2011 kept popping up questions on the Smarty forums, I finally felt the need to explain what I did. Although Smarty is the reason I discovered this, this post applies to PHP in general, not Smarty in particular. This post is all about laying the groundwork for you to realize two things:
- Your operations are not atomic
- Avoid accessing the hard disk unnecessarly
Many tools come with an installation / setup / configuration procedure. At this stage directories needed by the tool or its components usually don't yet exist. For Smarty based systems this poses a problem, as Smarty writes compiled templates to a designated directory. So if the installer is built upon Smarty, the developer is presented a hen/egg problem.Continue reading "Prevent Smarty from writing compiled templates"
Dealing with user-uploaded images in web applications has become dead simple - yet not simple enough. JPEG knows profiles and color spaces not every renderer understands correctly. This post illustrates how CMYK JPGs present accross browsers and how one can easily avoid those problems. (And show a neat trick to speed up ImageMagick on multi-core systems.)Continue reading "CMYK Images And Browsers And ImageMagick"