$drivers = PDO::getAvailableDrivers(); print_r($drivers);
Array ( [0] => mysql [1] => sqlite [2] => pgsql )
if (in_array('mysql', PDO::getAvailableDrivers())) { echo 'Mysql driver is available.
'; } else { echo 'Mysql driver is not available.
'; } if (in_array('pgsql', PDO::getAvailableDrivers())) { echo 'PostgreSQL driver is available.
'; } else { echo 'PostgreSQL driver is not available.
'; }
Mysql driver is available. PostgreSQL driver is not available.This example checks whether the mysql and pgsql drivers are available or not. The output shows that the mysql driver is available but pgsql is not. Package library: PDO is a core PHP extension and does not require any package/library installation.