Getting Detailed Information About Variables
The values of variables can be sent to the client using print() or echo(); however, this is sometimes problematic. Take Booleans, for instance. echo(true) prints 1, but echo(false) prints nothing. A much better way is to use var_dump(), a function that also prints the type of the variable. Therefore, this code returns the string bool(false).
This also works for objects and arrays, making var_dump() a must-have option for developers who like to debug without a debugger.
A function related to var_dump() is var_export(). It works similarly; however, there are two differences:
The return value of var_export() is PHP code; for instance, var_export(false) returns false. If the second parameter provided to var_export() is the Boolean true, the function does not print anything, but returns a string.
|
|