1--TEST-- 2ZE2 An interface is inherited 3--FILE-- 4<?php 5 6interface if_a { 7 function f_a(); 8} 9 10interface if_b extends if_a { 11 function f_b(); 12} 13 14class base { 15 function _is_a($sub) { 16 echo 'is_a('.get_class($this).', '.$sub.') = '.(($this instanceof $sub) ? 'yes' : 'no')."\n"; 17 } 18 function test() { 19 echo $this->_is_a('base'); 20 echo $this->_is_a('derived_a'); 21 echo $this->_is_a('derived_b'); 22 echo $this->_is_a('derived_c'); 23 echo $this->_is_a('derived_d'); 24 echo $this->_is_a('if_a'); 25 echo $this->_is_a('if_b'); 26 echo "\n"; 27 } 28} 29 30class derived_a extends base implements if_a { 31 function f_a() {} 32} 33 34class derived_b extends base implements if_a, if_b { 35 function f_a() {} 36 function f_b() {} 37} 38 39class derived_c extends derived_a implements if_b { 40 function f_b() {} 41} 42 43class derived_d extends derived_c { 44} 45 46$t = new base(); 47$t->test(); 48 49$t = new derived_a(); 50$t->test(); 51 52$t = new derived_b(); 53$t->test(); 54 55$t = new derived_c(); 56$t->test(); 57 58$t = new derived_d(); 59$t->test(); 60 61?> 62--EXPECT-- 63is_a(base, base) = yes 64is_a(base, derived_a) = no 65is_a(base, derived_b) = no 66is_a(base, derived_c) = no 67is_a(base, derived_d) = no 68is_a(base, if_a) = no 69is_a(base, if_b) = no 70 71is_a(derived_a, base) = yes 72is_a(derived_a, derived_a) = yes 73is_a(derived_a, derived_b) = no 74is_a(derived_a, derived_c) = no 75is_a(derived_a, derived_d) = no 76is_a(derived_a, if_a) = yes 77is_a(derived_a, if_b) = no 78 79is_a(derived_b, base) = yes 80is_a(derived_b, derived_a) = no 81is_a(derived_b, derived_b) = yes 82is_a(derived_b, derived_c) = no 83is_a(derived_b, derived_d) = no 84is_a(derived_b, if_a) = yes 85is_a(derived_b, if_b) = yes 86 87is_a(derived_c, base) = yes 88is_a(derived_c, derived_a) = yes 89is_a(derived_c, derived_b) = no 90is_a(derived_c, derived_c) = yes 91is_a(derived_c, derived_d) = no 92is_a(derived_c, if_a) = yes 93is_a(derived_c, if_b) = yes 94 95is_a(derived_d, base) = yes 96is_a(derived_d, derived_a) = yes 97is_a(derived_d, derived_b) = no 98is_a(derived_d, derived_c) = yes 99is_a(derived_d, derived_d) = yes 100is_a(derived_d, if_a) = yes 101is_a(derived_d, if_b) = yes 102