Troubleshooting in PHP

PHP can be trickier to debug and troubleshoot than JavaScript, because you can’t use the browser console in the same way.

Tips:

  • Use echo to show variable values in your page
  • Use var_dump() to display contents of arrays and objects. This works for things that can’t be displayed with the echo command.
  • Turn on more error reporting
  • Print the type of an object to see if it’s the correct type: use the gettype() function and echo the result.