How to Check for a Specific Type of Object in PHP
You can use instanceof: if ($pdo instanceof PDO) { // it’s PDO } Be aware though, you can’t negate like !instanceof, so you’d instead do: if (!($pdo instanceof PDO)) { // it’s not PDO } Also, looking over your question, you can use object type-hinting, which helps enforce requirements, as well as simplify your check … Read more