Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

[Coding / PHP] nuDebug() function

Video Tutorials, How-Tos, Tips & Tricks, and Guides.
kev1n
nuBuilder Team
Posts: 4291
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

[Coding / PHP] nuDebug() function

Unread post by kev1n »

The nuDebug() function is a PHP utility that helps developers debug their applications by logging information during code execution.

It accepts multiple types of inputs—such as strings, arrays, or objects—and writes them to a debug log that you can view in the "nuDebug Results" section of the application's menu.

Each entry in the debug log includes:
  • A timestamp
  • A description of the context (e.g., procedure name, event, or SQL error)
Examples of context labels:
  • Procedure – e.g., "Procedure ABC line 1"
  • Event – e.g., "Before Edit of Form nuhome line 5"
  • SQL Error – e.g., "SQL Error in nuRunQuery"
This function is particularly useful for:
  • Tracing execution flow
  • Inspecting variable contents
  • Debugging code
Example usage 1: Output a variable

Code: Select all

$a = 'Bob';
nuDebug($a);
Example usage 2: Set a categroy

Code: Select all

nuDebug::setFlag('Test')->log('Error: Failed to retrieve data..');
Example usage 3: Output multiple variables

Code: Select all

$s = 'Hello world';
$a = [1, 2, 3, 4];
$o = ['name' => 'Bob', 'phone' => '555 123456'];
nuDebug($s, $a, $o);
To view the output, open nuDebug Results from the Options menu or press CTRL+SHIFT+D after running your code.

Video: Using nuBuilder's debugger - nuDebug()



For more information, see:

nuBuilder PHP Documentation
Post Reply