3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on aX0eR
Output for 5.3.0 - 7.2.0
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.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.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.