dnd (function)

Last updated: Mon, Apr 17, 2023 7:40 am
Return to Knowledgebase

Purpose

Provides a formatted var_dump of a variable and kills the page

Location

users/helpers/helpers.php

See Also:

dump (function)

Parameters

# Parameter Data Type Required Description
1 $var No the variable to be dumped
2 $adminOnly = false bool No a boolean flag that indicates whether the dump should only be accessible to logged in administrators (defaults to false)
3 $localhostOnly = false bool No a boolean flag that indicates whether the dump should only be accessible when running on the localhost domain (defaults to false).

Returns

Data Type Description of Returned Data
nothing

Example

dnd($db->errorString);

Further Documentation:

Simply adds pre tags around each item in the var_dump for better formatting and clearer results. The best use for this is during debugging or right before a redirect when you want PHP to stop executing.

This is a debugging function in UserSpice that dumps the provided variable using the dump function (which pretty prints the variable for easy viewing) and then terminates the script with die().

$d = array('foo' => 'bar', 'baz' => 'qux');
dnd($d);

This would dump the contents of the $d array and then stop execution of the script.