如何检查对象是否是特定类的实例?
有没有办法检查一个对象是否是?SimpleXMLELement
private function output_roles($role) {
foreach ($role as $current_role) {
$role_ = $current_role->attributes();
$role_type = (string) $role_->role;
echo "<tr>";
echo "<td><b>" . $role_type . "</b></td>";
echo "</tr>";
$roles = $role->xpath('//role[@role="Administrator"]//role[not(role)]');
if (is_array($roles)) {
$this->output_roles($roles);
}
}
}
这是我的函数,仅当提供的对象是 .任何人?$role->xpath
SimpleXMLElement