Приглашаем посетить
Булгаков (bulgakov.lit-info.ru)

Getting Detailed Information About Variables

Previous
Table of Contents
Next

Getting Detailed Information About Variables

var_dump(false);


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.

NOTE

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.



Previous
Table of Contents
Next