3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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_char' in '$target'" ); }
based on Sk507
Output for 5.6.8 - 7.1.0
int(2) string(3) "♥" Notice: Undefined variable: bad_char in /in/Bu5ot on line 11 Notice: '' in 'AB♥' in /in/Bu5ot on line 11
Output for 5.0.4 - 5.5.35
int(2) string(1) "�" Notice: Undefined variable: bad_char in /in/Bu5ot on line 11 Notice: '' in 'AB♥' in /in/Bu5ot on line 11
Output for 5.0.0 - 5.0.3
int(2) string(1) "�" Notice: Undefined variable: bad_char in /in/Bu5ot on line 11 Notice: '' in 'AB♥' in /in/Bu5ot on line 11
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Bu5ot on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Bu5ot on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/Bu5ot on line 2
Process exited with code 255.