Skip to content

@sproutventure /php_helpers.php forked from Gipetto/php_helpers.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
PHP Dev Helpers
function pp() {
$msg = __v_build_message(func_get_args());
echo '<pre style="white-space:pre-wrap; text-align: left; '.
'font: normal normal 11px/1.4 menlo, monaco, monospaced; '.
'background: white; color: black; padding: 5px;">'.$msg.'</pre>';
}
function dp() {
$msg = __v_build_message(func_get_args(), 'var_dump');
echo '<pre style="white-space:pre-wrap;; text-align: left; '.
'font: normal normal 11px/1.4 menlo, monaco, monospaced; '.
'background: white; color: black; padding: 5px;">'.$msg.'</pre>';
}
function ep() {
$msg = __v_build_message(func_get_args());
error_log('**: '.$msg);
}
function __v_build_message($vars, $func = 'print_r', $sep = ', ') {
$msgs = array();
if (!empty($vars)) {
foreach ($vars as $var) {
if (is_bool($var)) {
$msgs[] = ($var ? 'true' : 'false');
}
elseif (is_scalar($var)) {
$msgs[] = $var;
}
else {
switch ($func) {
case 'print_r':
case 'var_export':
$msgs[] = $func($var, true);
break;
case 'var_dump':
ob_start();
var_dump($var);
$msgs[] = ob_get_clean();
break;
}
}
}
}
return implode($sep, $msgs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.