Firehed's Blog

New Theme and a quick PHP tip

I just switched over to a new theme for the blog: Sharp, available at ThemeForest.  A bit snazzier, I think.  A few tweaks made, mostly to the code sections.  People with newer browsers that support CSS3's @font-face rule should get snippets in Panic Sans, which I extracted from my copy of Coda, in a slightly smaller than default size and with better overflow handling.  I'll assume everything still looks decent in IE, but I don't have easy access to a Windows machine and honestly don't give a damn since I focus primarily on back-end code where I can (and do) set requirements to use standards-compliant browsers.

Now on to a quick tip... PHP coders who also use jQuery might enjoy this.  If you're writing OO PHP and have setters for protected/private class members, use return $this; instead of return true; (or a return-less void) at the end of your setter method.  It mimics jQuery's "chainability" concept by returning the modified object.  So you can go from this:


To this:


Small change, but I find it a bit more readable and there's no discernable performance impact. And while I haven't looked into it in any detail, I'm pretty sure this is (more or less) how PHP's SimpleXML class works.