ReflectionClass::isInstance

(PHP 5)

ReflectionClass::isInstanceبررسی کلاس برای نمونه

Description

public bool ReflectionClass::isInstance ( object $object )

بررسی نمونه بودن از شی.

Parameters

object

شی برای مقایسه.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 مثال مرتبط ReflectionClass::isInstance()

<?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";
}
?>

The above example will output something similar to:

Yes
Yes
Yes

See Also

add a note add a note

User Contributed Notes 1 note

up
0
dhairya lakhera
7 months ago
class  TestClass { }

$TestObj=new TestClass();

$TestObj_assigned=$TestObj;
$TestObj_Refrenced=&$TestObj;
$TestObj_cloned=clone $TestObj;

$obj=new ReflectionClass('TestClass');

var_dump($obj->isInstance($TestObj));
var_dump($obj->isInstance($TestObj_assigned));
var_dump($obj->isInstance($TestObj_Refrenced));
var_dump($obj->isInstance($TestObj_cloned));
To Top