How to Check if PDO is enabled in my PHP on Apache Installation? CodeUnit 13 DEC 2012

PDO is a popular way of managing database connections and activities in the LAMP stack, though it isn’t always turned on by default unfortunately.

Lucky for us, the following simple PHP code snippet runs a simple enough check and then alerts us to the status, making it a breeze to pick up on whether of not PDO is actually available or not.

if (!defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO unavailable';
elseif (defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO available';

Simple but rather effective.

About Craig Lotter

Software developer, husband and dad to two young ladies. Writer behind An Exploring South African. I don't have time for myself any more.