<?php
try {
    $p = new PDO("mysql:host=localhost", 'root', '');
    $stmt = $p->query("SHOW DATABASES");
    $dbs = $stmt->fetchAll(PDO::FETCH_COLUMN);
    echo "<h1>Local Databases</h1><ul><li>" . implode("</li><li>", $dbs) . "</li></ul>";
} catch (Exception $e) {
    echo "<h1>Error</h1>" . $e->getMessage();
}
?>