If the given argument is not an array it will take the necessary action according to its data type. If the argument is an array, print_r()
is used. If the argument is a object, var_dump()
is used – with <pre>
formatting. If it is anything else, it is printed with a var_dump()
.
/** Function : dump()
* Prints a array, an object or a scalar variable in an easy to view format.
*
* @param $data - the variable that must be displayed
*/
function dump( $data ) {
print "<pre style=' background: rgba(0, 0, 0, 0.1); margin-bottom: 1.618em; padding: 1.618em; overflow: auto; max-width: 100%; '>==========================n";
if ( is_array( $data ) ) {
print_r( $data );
} elseif ( is_object( $data ) ) {
var_dump( $data );
} else {
var_dump( $data );
}
print "===========================</pre>";
}