What can use for DateTime::diff() for PHP 5.2?

Spudley’s answer doesn’t work for me–subtracting any DateTime from another gives 0 on my system. I was able to get it to work by using DateTime::format with the ‘U’ specifier (seconds since Unix epoch): $start = new DateTime(‘2010-10-12’); $end = new DateTime(); $days = round(($end->format(‘U’) – $start->format(‘U’)) / (60*60*24)); This works on both my dev … Read more

How to get protected property of object in PHP

Here’s the really simple example (with no error checking) of how to use ReflectionClass: function accessProtected($obj, $prop) { $reflection = new ReflectionClass($obj); $property = $reflection->getProperty($prop); $property->setAccessible(true); return $property->getValue($obj); } I know you said you were limited to 5.2, but that was 2 years ago, 5.5 is the oldest supported version and I’m hoping to help … Read more