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 git.master, git.master_jit, rfc.property-hooks
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
53.93 ms | 401 KiB | 8 Q