3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Tester { const EMERG = 0; // Emergency: system is unusable const ALERT = 1; // Alert: action must be taken immediately const CRIT = 2; // Critical: critical conditions const ERR = 3; // Error: error conditions const WARN = 4; // Warning: warning conditions const NOTICE = 5; // Notice: normal but significant condition const INFO = 6; // Informational: informational messages const DEBUG = 7; // Debug: debug messages private static $MESSAGE_PREFIXES = array ( Tester::EMERG => "\033[1;31m{EMERG}\033[0m ", Tester::ERR => "\033[1;31m{ERR}\033[0m ", Tester::CRIT => "\033[1;31m{CRIT}\033[0m ", Tester::WARN => "\033[1;33m{WARN}\033[0m ", Tester::DEBUG => "{DEBUG} ", Tester::INFO => "{INFO} ", Tester::NOTICE => "{NOTIC} ", Tester::ALERT => "{ALERT} " ); private static function addPrefix($message, $priority) { // ADDING COLOUR YAYYYY if(array_key_exists($priority, $MESSAGE_PREFIXES)){ // item is in the hastable $prefix = str_pad($MESSAGE_PREFIXES[$priority], 6, " "); $message = $prefix . $message; } return $message; } public static function myLog($message, $priority = Tester::DEBUG, $extras = null) { $message = Tester::addPrefix($message, $priority); echo $message . "\n"; } }; $path = "Blalala"; Tester::myLog("Saving file to third party at : $path", Tester::INFO); Tester::myLog(" "); Tester::myLog("GGSN plugin of monthly usage fraud found ", Tester::INFO); Tester::myLog("ggsnPlugin::handlerCollect collecting hourly data exceeders", Tester::DEBUG); Tester::myLog("Couldn't save file to third patry path at : $path", Tester::ERR); Tester::myLog("Couldn't find flat price for subscriber for billrun ", Tester::ALERT);
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
Warning: Undefined variable $MESSAGE_PREFIXES in /in/PrZd7 on line 29 Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /in/PrZd7:29 Stack trace: #0 /in/PrZd7(41): Tester::addPrefix('Saving file to...', 6) #1 /in/PrZd7(48): Tester::myLog('Saving file to...', 6) #2 {main} thrown in /in/PrZd7 on line 29
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, unknown given in /in/PrZd7 on line 29 Saving file to third party at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, unknown given in /in/PrZd7 on line 29 Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, unknown given in /in/PrZd7 on line 29 GGSN plugin of monthly usage fraud found Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, unknown given in /in/PrZd7 on line 29 ggsnPlugin::handlerCollect collecting hourly data exceeders Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, unknown given in /in/PrZd7 on line 29 Couldn't save file to third patry path at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, unknown given in /in/PrZd7 on line 29 Couldn't find flat price for subscriber for billrun
Output for 7.3.32 - 7.3.33
Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Saving file to third party at : Blalala Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 GGSN plugin of monthly usage fraud found Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 ggsnPlugin::handlerCollect collecting hourly data exceeders Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Couldn't save file to third patry path at : Blalala Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Couldn't find flat price for subscriber for billrun
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, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Saving file to third party at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 GGSN plugin of monthly usage fraud found Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 ggsnPlugin::handlerCollect collecting hourly data exceeders Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Couldn't save file to third patry path at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/PrZd7 on line 29 Couldn't find flat price for subscriber for billrun
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Saving file to third party at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 GGSN plugin of monthly usage fraud found Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 ggsnPlugin::handlerCollect collecting hourly data exceeders Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Couldn't save file to third patry path at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Couldn't find flat price for subscriber for billrun
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Saving file to third party at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 GGSN plugin of monthly usage fraud found Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 ggsnPlugin::handlerCollect collecting hourly data exceeders Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Couldn't save file to third patry path at : Blalala Notice: Undefined variable: MESSAGE_PREFIXES in /in/PrZd7 on line 29 Warning: array_key_exists(): The second argument should be either an array or an object in /in/PrZd7 on line 29 Couldn't find flat price for subscriber for billrun
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/PrZd7 on line 4
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_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/PrZd7 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/PrZd7 on line 4
Process exited with code 255.

preferences:
362.17 ms | 401 KiB | 459 Q