dump (function)

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

Purpose

Provides a formatted var_dump of a variable

Location

users/helpers/helpers.php

See Also:

dnd (function)

Parameters

# Parameter Data Type Required Description
1 $var Yes The variable to be dumped.
2 $adminOnly = false bool No A boolean flag indicating whether the dump should only be displayed for users with admin privileges. Default is false.
3 $localhostOnly = false bool No A boolean flag indicating whether the dump should only be displayed if the code is running on localhost. Default is false.
4 $fromdnd = false Yes undocumented

Returns

Data Type Description of Returned Data
nothing

Example

dump($db->errorString);

Further Documentation:

Simply adds pre tags around each item in the var_dump for better formatting and clearer results.
Example usage:

// Dump the contents of a variable
$myVar = [1, 2, 3];
dump($myVar);

// Only display the dump for admin users
dump($myVar, true);

// Only display the dump if running on localhost
dump($myVar, false, true);

// Only display the dump for admin users running on localhost
dump($myVar, true, true);