How to check the contents of PHP variables

PHP uses functions such as print_r(), var_dump(), and var_export() to check the contents of variables. These functions also display the protected and private properties of the object. However, static class members are not displayed.

  • print_r(): prints array and object information in a readable form.
  • var_dump(): prints the type and value of a variable. In the case of an object, the class name and members are also printed together.
  • var_export( ): Returns or outputs variable information as a string. Optionally, arrays and objects can be output as executable PHP code.

By using these functions, the contents of variables can be checked during debugging.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top