3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class App_Messages{ protected static $ANSI_CODES = array( "Reset" => 0, "Bold" => 1, "Italic" => 3, "Underline" => 4, "Blink" => 5, "Inverse" => 7, "Hidden" => 8, "BLK" => 30, "RED" => 31, "GRN" => 32, "YEL" => 33, "BLU" => 34, "PUR" => 35, "CYN" => 36, "WHT" => 37, "BLK_bg" => 40, "RED_bg" => 41, "GRN_bg" => 42, "YEL_bg" => 43, "BLU_bg" => 44, "PUR_bg" => 45, "CYN_bg" => 46, "WHT_bg" => 47 ); public static function printToScreen($message,$format = NULL) { echo EOL.self::set($message,$format).EOL; } public static function set($str, $color = NULL) { if (!isset($color)) { return $str; } $color_attrs = explode("+", $color); $ansi_str = ""; foreach ($color_attrs as $attr) { $ansi_str .= "\033[" . self::$ANSI_CODES[$attr] . "m"; } $ansi_str .= $str . "\033[" . self::$ANSI_CODES["Reset"] . "m"; return $ansi_str; } public static function replace($full_text, $search_regexp, $color) { $new_text = preg_replace_callback( "/($search_regexp)/", function ($matches) use ($color) { return App_Messages::set($matches[1], $color); }, $full_text ); return is_null($new_text) ? $full_text : $new_text; } } App_Messages::printToScreen("HELLO","BLU+Bold");
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "EOL" in /in/QYEp7:32 Stack trace: #0 /in/QYEp7(70): App_Messages::printToScreen('HELLO', 'BLU+Bold') #1 {main} thrown in /in/QYEp7 on line 32
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant EOL - assumed 'EOL' (this will throw an Error in a future version of PHP) in /in/QYEp7 on line 32 Warning: Use of undefined constant EOL - assumed 'EOL' (this will throw an Error in a future version of PHP) in /in/QYEp7 on line 32 EOLHELLOEOL
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Notice: Use of undefined constant EOL - assumed 'EOL' in /in/QYEp7 on line 32 Notice: Use of undefined constant EOL - assumed 'EOL' in /in/QYEp7 on line 32 EOLHELLOEOL
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/QYEp7 on line 61
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/QYEp7 on line 61
Process exited with code 255.
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/QYEp7 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QYEp7 on line 5
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/QYEp7 on line 5
Process exited with code 255.

preferences:
294.19 ms | 401 KiB | 456 Q