I wasted more time golfing this week than I should have. No, not real golf... code golf . Trying to write small programs in the least number of keystrokes can be fun, challenging, and sometimes even addicting. It's not about writing pretty code or code that's easily-understandable. It's all about cramming as much code as you can into the least number of characters. While some languages golf better than others, you can still write impressively small code in your language of choice if you're familiar enough with the intricacies of its behavior. Here are 8 tips to improve your golf score when golfing with PHP: Use short tags. Using <? instead of <?php and using <?= instead of <?echo will both save you 3 characters. Avoid initializing variables if possible. Uninitialized variables assume the value 0 , "" , or false depending on the context in which they're referenced. $x=0; is 5 characters too much! Know your function aliases. A few...
The Blog of Timothy Boronczyk - running my mouth off one blog post at a time