Reputation: 79686
how do i check if a variable is of a type mysqli object?
Upvotes: 16
Views: 10632
Reputation: 1477
Тhe decision of Gumbo works, but in this case must check if $var
is instance of mysqli_result
, i.e.
$var instanceof mysqli_result;
is_a($var, 'mysqli_result');
get_class($var) == 'mysqli_result';
Upvotes: 9
Reputation: 94147
You'll probably want the instanceof operator.
It will work for derived classes as well, in the odd case that you extending or building your own wrappers.
Upvotes: 3
Reputation: 655219
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'
Upvotes: 34