How to determine if PDO is enabled in PHP?

后端 未结 6 1597
轻奢々
轻奢々 2020-12-01 09:13

Is there a PHP command I can use to determine if PDO is enabled or disabled?

I know I an manually run phpinfo() and eyeball it, but I have a script I run various web

6条回答
  •  离开以前
    2020-12-01 09:53

    The proper way of determining that will be using the extension_loaded function:-

    if ( extension_loaded('pdo') ) {
        .......
    }
    

    And you might also want to check for the database-specific PDO driver using:-

    if ( extension_loaded('pdo_') ) { // e.g., pdo_mysql
        .......
    }
    

提交回复
热议问题