how do i check if a variable is of a type mysqli object?
The is_object() function checks whether a variable is an object. This function returns true (1) if the variable is an object, otherwise it returns false/nothing.
Return Values ¶ For successful queries which produce a result set, such as SELECT, SHOW, DESCRIBE or EXPLAIN , mysqli_query() will return a mysqli_result object. For other successful queries, mysqli_query() will return true .
Try the instanceof
operator, the is_a
function or the get_class
function:
$var instanceof MySQLi
is_a($var, 'mysqli')
is_object($var) && get_class($var) == 'mysqli'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With