php - what means if ($con->connect_errno)? -
i'm learning php , have file connects mysql database, i'd know condition inside brackets of following "if structure" in file, $con instance of class mysqli:
if ($con->connect_errno) { echo "fail connect mysql"; }
i know $con invoking connect_errno conditioning if(what?){...}?
that's status flag mysqli handles.
see http://php.net/manual/en/mysqli.connect-errno.php
it's not function, property (or "variable" if will). it's 0
when connection correctly established. contains other values (e.g. 1043
) connection problems (such wrong password, inavailable database server).
so if ($con->connect_errno)
check asserts $con
instance usable.
- when
->connect_errno == 0
if
block skipped. - if
->connect_errno > 0
(any other value) error message printed out. (you'd more commonly seedie()
,trigger_error()
ornew exception()
echo
there.)
alternatively mysqli can configured throw error/exception itself. make whole condition/block redundant.
Comments
Post a Comment