note 126305 added to exception.getcode
| From: | 2M at main dot php dot net | Date: | Mon, 02 Aug 2021 18:50:36 +0000 |
| Subject: | note 126305 added to exception.getcode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216724@lists.php.net to get a copy of this message | ||
Do not use the strict operator as suggested when checking the Exception Code in \PDOException.
As per documentation: \PDOException is returning a string for its Exception Code and not an Integer.
Ran into the following in PHP8:
<?php
catch(\PDOException $e) {
var_dump($e->getCode()); //Output: string(5) "23000"
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 195.181.160.247)
----
Manual Page -- https://php.net/manual/en/exception.getcode.php
Edit -- https://main.php.net/note/edit/126305
Del: integrated -- https://main.php.net/note/delete/126305/integrated
Del: useless -- https://main.php.net/note/delete/126305/useless
Del: bad code -- https://main.php.net/note/delete/126305/bad+code
Del: spam -- https://main.php.net/note/delete/126305/spam
Del: non-english -- https://main.php.net/note/delete/126305/non-english
Del: in docs -- https://main.php.net/note/delete/126305/in+docs
Del: other reasons-- https://main.php.net/note/delete/126305
Reject -- https://main.php.net/note/reject/126305
Search -- https://main.php.net/manage/user-notes.php