How to determine if PDO is enabled in PHP?

后端 未结 6 1603
轻奢々
轻奢々 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:32

    You have two options:

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

    Or (this one is not 100% reliable since it can be implemented in user-land classes):

    if (class_exists('PDO', false)) { /* ... */ }
    

    Personally, I prefer the first option.

提交回复
热议问题