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.

alternatively mysqli can configured throw error/exception itself. make whole condition/block redundant.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -