Skip to content

Instantly share code, notes, and snippets.

Last active Jun 22, 2017
What would you like to do?
PHP redbox for errors
$errors = array();
function redbox($no, $str, $file, $line) {
global $errors;
$errors[] = array(
'no' => $no,
'str' => $str,
'file' => $file,
'line' => $line,
.redbox {
overflow-y: auto;
position: fixed;
background: #e91e00;
color: #fff;
z-index: 999;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: flex-start;
.redbox ul {
margin-top: -40px;
.redbox li {
padding-top: 40px;

This comment has been minimized.

Copy link
Owner Author

@joecritch joecritch commented Jun 22, 2017

This sets a custom error handler, which collects the errors into an associative array, allowing you to output them elsewhere. This UI is similar to the redbox, common in JavaScript, etc. Ensures you have less runtime errors.

This could really do with a stack trace, lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment