3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class States { const STATUS_PASSED = 'ok'; const STATUS_FAILED = 'failed'; const DONT_USE = 'lolol'; public function reflect() { $x = new \ReflectionClass($this); $consts = $x->getConstants(); $statuses = array_filter($consts, function($value, $key) { return strpos($key, 'STATUS') !== false; }, ARRAY_FILTER_USE_BOTH); var_dump($statuses); } } $x = new States; $x->reflect();
Output for 5.6.8 - 7.2.0
array(2) { ["STATUS_PASSED"]=> string(2) "ok" ["STATUS_FAILED"]=> string(6) "failed" }
Output for 5.3.0 - 5.5.35
Notice: Use of undefined constant ARRAY_FILTER_USE_BOTH - assumed 'ARRAY_FILTER_USE_BOTH' in /in/X9FdB on line 15 Warning: array_filter() expects at most 2 parameters, 3 given in /in/X9FdB on line 15 NULL
Output for 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/X9FdB on line 10 Parse error: syntax error, unexpected T_FUNCTION in /in/X9FdB on line 13
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/X9FdB on line 10 Parse error: parse error, unexpected T_FUNCTION in /in/X9FdB on line 13
Process exited with code 255.
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/X9FdB on line 4
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/X9FdB on line 4
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/X9FdB on line 4
Process exited with code 255.