check if a variable is of type mysqli object?

2019-04-19 09:21发布

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

标签: php mysqli
5条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-19 09:58

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-04-19 09:58

Take a look at get_class

查看更多
姐就是有狂的资本
4楼-- · 2019-04-19 10:05

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'
查看更多
疯言疯语
5楼-- · 2019-04-19 10:07

Т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';
查看更多
登录 后发表回答