有沒有辦法檢查一個對象是否是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
。任何人?
可能重複的[如何在PHP中檢查特定類型的對象](http://stackoverflow.com/questions/8091143/how-to-check-for-a-specific-type-of -object-in-php) – IMSoP