3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test{ const AB♥ = "alphabet"; } $rc = new ReflectionClass("Test"); $bad = "♥"; $key = array_keys( $rc->getConstants() ); $target = $key[ 0 ]; //php5.6: if ( mb_substr( $target, -1,1) == $bad ) { $pos = strpos( $target, $bad ); var_dump( $pos,mb_substr( $target, $pos,1 )); if ($pos !== FALSE) { trigger_error( "'$bad' in '$target'" ); }

preferences:
44.35 ms | 402 KiB | 5 Q