Author: Josh Sherman

  • Check if a PHP class exists

    We’ve discussed how to check if a class has a function but what if the class doesn’t exist at all? To check if a class exists you can use, use guessed it, class_exists(). if (class_exists(‘MyClass’)) { $object = new MyClass(); } else { throw new Exception(‘The class MyClass does not…

  • Check if a PHP class has a certain function

    We’ve previously discussed how to check if a function exists but that only works on standalone functions like the ones built into PHP as well as any user defined functions. Luckily there’s a function for that called method_exists(). When speaking in the scope of a class, the functions are referred…

  • WP Engine Review

    Now that I’m back on the WordPress bandwagon and have been using WPEngine for a bit of time now, it’s time to talk about it. As previously discussed, I opted to use a hosted WordPress solution because of my utter disdain for administering WordPress. When researching WordPress hosts, I got…

  • Check if a PHP function exists

    Let’s use json_encode as an example here. Prior to PHP 5.2.0 JSON support was only available via a PECL extension and since 5.2.0 it’s been available as part of the PHP core. You could check that the server is running PHP 5.2.0 or above, but that could result in a…

  • Detect Required PHP Version

    If you write and/or use open source software, you know that running an up to date version of PHP is a must. This can be a problem sometimes, like if you are running on a host that doesn’t run the most up to date version of PHP. Another scenario would…

  • Convert Errors to Exceptions in PHP

    I was having a conversation with a buddy of mine the other day and we got on the topic of PHP not having a very standardized error system. Now that he’s working with Python the mix of errors and exceptions in PHP is an apparent shortcoming. PHP is funny like…

  • Rediscovering WordPress

    If you’ve followed this blog for long enough you know that I’ve been through quite a few platform solutions over the years. Started with a homegrown blog, moved to WordPress, back again, moved to Tumblr and finally settling on Jekyll & Github because of it’s simplicity as well as the…

  • Speed up PHP with APC

    The Alternative PHP Cache (APC) is a PECL package that provides an opcode cache for PHP. Rasmus Lerdorf is the lead of the project along with a handful of other developers. What is an opcode cache? Before I can answer that, let’s discuss how PHP works. Because it is an…

  • Why I always wear a helmet

    When I first starting biking as my primary mode of transportation to my office I felt like I was wearing a helmet mainly because I hadn’t rode a bike in something like 15 years. It’s true what they say, you never forget how to ride a bike (barring a debilitating…

  • How to Build a Leaderboard with PHP and Redis

    One of biggest draws to Redis for me is the fact that it has more data structure types than just key / value. These additional data structures allow you to do some amazing things while still benefitting from being in-memory. One of the most notable ways to leverage Redis would…