PHP: Output a snapshot of all defined variables

Simply input the snippet below into any PHP file and you’ll get a browser-friendly snapshot of all variables defined in the current scope. This is especially handy in larger systems like WordPress or Smarty where a needed value may already be defined by the system but you have no way of knowing the variable’s name.

<?php
  print_r(get_defined_vars());
?>

Leave a Reply