Skip to content

Instantly share code, notes, and snippets.

@panayotoff
Last active January 10, 2019 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panayotoff/5c3cbeee3c5f45ed17d36b044d4bcf48 to your computer and use it in GitHub Desktop.
Save panayotoff/5c3cbeee3c5f45ed17d36b044d4bcf48 to your computer and use it in GitHub Desktop.
Helper to pretty output variable
function pre($var){
$styles = [
'display:block',
'padding:1em',
'margin:1em',
'border-radius:3px',
'font-size:14px',
'font-family: monospace',
'white-space: pre-wrap',
'word-wrap: break-word',
'overflow-x:auto',
'color: #004267',
'border:1px solid #00426733',
'box-shadow: 0 1px 1px rgba(0,0,0,0.08)',
'line-height:1.5em',
'text-align:left',
'white-space:pre',
'overflow-x:auto',
'background-image: linear-gradient(180deg, #eaeaea 50%, #fff 50%)',
'background-size: 100% 3em', // Double the line height
'background-position: 0 1em;' // Offset by top padding
];
echo sprintf('<pre style="%s">%s</pre>',
implode(';', $styles),
var_export($var, true)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment