1--TEST-- 2ReflectionClass::hasConstant() 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8class C { 9 const myConst = 1; 10} 11 12class D extends C { 13} 14 15 16$rc = new ReflectionClass("C"); 17echo "Check existing constant: "; 18var_dump($rc->hasConstant("myConst")); 19echo "Check existing constant, different case: "; 20var_dump($rc->hasConstant("MyCoNsT")); 21echo "Check absent constant: "; 22var_dump($rc->hasConstant("doesntExist")); 23 24 25$rd = new ReflectionClass("D"); 26echo "Check inherited constant: "; 27var_dump($rd->hasConstant("myConst")); 28echo "Check absent constant: "; 29var_dump($rd->hasConstant("doesntExist")); 30?> 31--EXPECTF-- 32Check existing constant: bool(true) 33Check existing constant, different case: bool(false) 34Check absent constant: bool(false) 35Check inherited constant: bool(true) 36Check absent constant: bool(false) 37