PHP 5.6.0RC3 is available

ReflectionClass::isInstance

(PHP 5)

ReflectionClass::isInstanceChecks class for instance

Descrição

public bool ReflectionClass::isInstance ( object $object )

Checks if an object is an instance of a class.

Parâmetros

object

The object being compared to.

Valor Retornado

Retorna TRUE em caso de sucesso ou FALSE em caso de falha.

Exemplos

Exemplo #1 ReflectionClass::isInstance() related examples

<?php
// Example usage
$class = new ReflectionClass('Foo');

if (
$class->isInstance($arg)) {
    echo 
"Yes";
}

// Equivalent to
if ($arg instanceof Foo) {
    echo 
"Yes";
}

// Equivalent to
if (is_a($arg'Foo')) {
    echo 
"Yes";
}
?>

O exemplo acima irá imprimir algo similar à:

Yes
Yes
Yes

Veja Também

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top