I have the following file with the function fred(…) which I include for debugging purposes:
fred.php
<?php declare(strict_types=1);
//===============================
// usage:
// fred($val); // uses print_r(...)
// fred($val, TRUE); // uses var_dump(...)
//===============================
function fred($val='Nothing passed???', $vd=FALSE)
{
$style='width: 88%; margin: 1em auto; background-color: #ffd; color: #000';
echo '<pre style="' .$style .'">';
if( $vd ) :
var_dump($val);
else:
print_r($val);
endif;
echo '</pre>';
}///
Calling fred( $any_variable_type_including_objects ) will format the variable details:
Example - fred($_SERVER) :
1 Like