[PHP] Show/print all variables in use.

Dieser Beitrag ist auch verfügbar in: German

Hi,

today I asked myself how the variables look like at the end of my script. I mean I use variables, include scripts, make database requests… and I always try to care to unset the variables again when I don’t need them anymore. But to I get all… or does my script use more and more memory? And how can I control it?

PHP have also for this question a solution. get_defined_vars() shows all variables which are currently in use.

print_r(get_defined_vars());

Call this function at the end (or somewhere between) and you know exactly which variables are in use and where you have to clean up.

Very nice :-)

Best regards
Gordon

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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


*