3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyClass { private static $data = array( 'banana', 'cherry', 'apple' ); private static function sort_by_text( $first, $second ) { return strcasecmp( $first, $second ); } public static function sorted_data() { usort( self::$data, array( __CLASS__, 'sort_by_text' ) ); return self::$data; } } print_r( MyClass::sorted_data() ); $data = array( 'banana', 'cherry', 'apple' ); usort( $data, array( __CLASS__, 'sort_by_text' ) );
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Array ( [0] => apple [1] => banana [2] => cherry ) Warning: usort() expects parameter 2 to be a valid callback, class '' not found in /in/gaFo3 on line 17
Output for hhvm-3.10.0 - 3.12.0
Array ( [0] => apple [1] => banana [2] => cherry ) Warning: Invalid argument: function: class not found in /in/gaFo3 on line 17
Output for 5.2.5 - 5.2.17
Array ( [0] => apple [1] => banana [2] => cherry ) Warning: usort(): Invalid comparison function in /in/gaFo3 on line 17
Output for 5.0.0 - 5.2.4
Array ( [0] => apple [1] => banana [2] => cherry ) Warning: usort(): Invalid comparison function. in /in/gaFo3 on line 17
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/gaFo3 on line 3
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_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/gaFo3 on line 3
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/gaFo3 on line 3
Process exited with code 255.