1--TEST-- 2ReflectionClass::isInstance() 3--FILE-- 4<?php 5class A {} 6class B extends A {} 7 8interface I {} 9class C implements I {} 10 11class X {} 12 13$classes = array("A", "B", "C", "I", "X"); 14 15$instances = array( "myA" => new A, 16 "myB" => new B, 17 "myC" => new C, 18 "myX" => new X ); 19 20foreach ($classes as $class) { 21 $rc = new ReflectionClass($class); 22 23 foreach ($instances as $name => $instance) { 24 echo "is $name a $class? "; 25 var_dump($rc->isInstance($instance)); 26 } 27 28} 29 30?> 31--EXPECT-- 32is myA a A? bool(true) 33is myB a A? bool(true) 34is myC a A? bool(false) 35is myX a A? bool(false) 36is myA a B? bool(false) 37is myB a B? bool(true) 38is myC a B? bool(false) 39is myX a B? bool(false) 40is myA a C? bool(false) 41is myB a C? bool(false) 42is myC a C? bool(true) 43is myX a C? bool(false) 44is myA a I? bool(false) 45is myB a I? bool(false) 46is myC a I? bool(true) 47is myX a I? bool(false) 48is myA a X? bool(false) 49is myB a X? bool(false) 50is myC a X? bool(false) 51is myX a X? bool(true) 52