Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if a variable is of type mysqli object?

Tags:

php

mysqli

how do i check if a variable is of a type mysqli object?

like image 587
ajsie Avatar asked Feb 04 '10 20:02

ajsie


People also ask

How to check that variable type is object in PHP?

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.

What does Mysqli_query return for insert?

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 .


1 Answers

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'
like image 180
Gumbo Avatar answered Sep 19 '22 13:09

Gumbo