The two “shortcut” functions “d()” and “e()” can be used anywhere in your application.
In the views one should use “” to echo and NOT the normal “echo”. This function escapes the variable (using “htmlspecialchars” with ENT_QUOTES flag and ‘UTF-8’ encoding) to prevent Cross-Site-Scripting (XSS) attacks.
The “d” (for debug) function logs the contents of a variable to the “Logging” panel of the debugger. In the debugger the file and line number of the invocation will also be logged. If the debugger is not loaded (in production) then calls to the function are ignored. To reduce memory usage this function limits the output:
- Only the first 100 characters of each string are logged.
- Only the first 25 elements of an array are logged.
- Only the first 10 levels of nested objects/arrays are logged.
These 3 limits can be set using 3 optional parameters in the above order. Hence, calling “d($variable)” is equal to calling “d($variable,100,25,10)”.