3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorLog { function throwError ($err, $level = E_USER_WARNING, $suppress = false, $shiftBack = 1) { // Shiftback means: look back into the backtrace calls, shifting that amount of calls, and then report the error. // There is no checking whether this many levels actually exist in the call stack, make sure yourself // Error log doesn't show newlines. str_replace( array( "\n" ), array( " " ), $err ); $trace = $this->getBacktrace(); $info = ""; if (!empty($trace)) { while ($shiftBack > 0) { array_shift($trace); --$shiftBack; } // Error file/line information: $info .= "in " . $trace[0]["file"] . ":" . $trace[0]["line"] . "."; // Caller information: if (count($trace) > 1) { array_shift($trace); $caller = $trace[0]; $info .= " Thrown by "; if (isset($caller["function"])) { if (isset($caller["class"])) { $info .= $caller["class"] . "::"; } $info .= $caller["function"] . "() "; } else { $info .= "global scope "; } $info .= "which was called in " . $caller["file"] . ":" . $caller["line"] . "."; } } $out = "\"" . $err . "\" " . $info; if (!$suppress) { trigger_error($out, $level); } } function throwDeprecated ($suppress = false) { // Call this method from INSIDE a deprecated function, $this->throwError("Deprecated!", E_USER_NOTICE, $suppress, 2); } function getBacktrace () { if (version_compare(PHP_VERSION, "5.2.5", "<")) { return debug_backtrace(); } else { return debug_backtrace(false); // A bit more efficient } } } function a () { ErrorLog::throwDeprecated(); } a();
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Non-static method ErrorLog::throwDeprecated() cannot be called statically in /in/3uTY0:75 Stack trace: #0 /in/3uTY0(78): a() #1 {main} thrown in /in/3uTY0 on line 75
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:
56.22 ms | 401 KiB | 8 Q