How to use try/catch statements in PHP. Oh, and finally too!

By Josh Sherman
3 min read
development
php

I do a lot of coding in Python and one thing that I really love is the mindset of asking for forgiveness instead of permission. What’s this mean? It means that instead of sanity checking every little thing, just handling the exceptions that are thrown instead. In PHP this can […]

Gravatar as an identicon generation service

By Josh Sherman
2 min read
development

If you’re not already aware, Gravatar is a free service that allows you to couple an image to your email address which can then be carried around the Internet with you. It’s great for site owners because then you don’t have to build out image uploading and storage and it’s […]

Your stack is outdated

By Josh Sherman
4 min read
development
php

I’ve been noticing a pattern with most of my peers (yes I said most), they expect their users to be running the latest and greatest version of their favorite “modern” browser and all the while their server stack is collecting dust. Ubuntu doesn’t help matters with their Long Term Service […]

How to use switch/case statements in PHP

By Josh Sherman
2 min read
development
php

switch/case statements are one of my favorite anti-patterns not because I prefer to write spaghetti code but because they can make if/elseif blocks look a ton cleaner. Why would it be considered an anti-pattern? Because it could easily be abused to the point that you are munging up your control […]

Improve performance by reusing PHP objects

By Josh Sherman
1 min read
development
php

I’ve been doing a ton of optimizations on one of my main sites and one thing that I’ve been doing more and more is trying to reuse objects whenever possible. What’s this entail? All it takes is creating a static function to return an instance of the object instead of […]