|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-05-12 15:56 UTC] vedad at kajtaz dot net
Description: ------------ The documentation states that mysqli::$errno is an integer. Once the mysqli connection was closed, it resolves to boolean false instead. This is annoying when mysqli::$errno is being passed as second argument to \Throwable, which triggers an Error with strict_types enabled. Test script: --------------- $mysqli = mysqli_init(); assert(is_int($mysqli->errno) && 'before connect'); assert($mysqli->real_connect(...)); assert(is_int($mysqli->errno) && 'before close'); $mysqli->close(); assert(is_int($mysqli->errno) && 'after close'); Actual result: -------------- PHP Fatal error: Uncaught AssertionError: assert(is_int($mysqli->errno) && 'after close') PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 03:00:02 2025 UTC |
After closing the connection, the connection is no longer valid. In PHP 7 this should trigger a warning like "Couldn't fetch mysqli". In PHP 8 the warning will be elevated to an exception ("mysqli object is already closed"). So you really should not access a closed mysqli object. So this is not a bug, but it makes sense to document this behavior more prominently.