Vish
Vish

Reputation: 4492

Printing all defined variables and values

<?php echo ‘<pre>’; print_r(get_defined_vars()); echo ‘</pre>’; ?>

This is just giving me the arrays for defined variables but not priniting out any variables. How can I print values too?

Also what function can I use to output all the defined variables in this format:

Variable name | Variable Type [int, array, string, bool] | Variable defined on line | Variable defined in script | Variable used times | Variable Value

Upvotes: 24

Views: 45552

Answers (2)

Steve
Steve

Reputation: 1095

Have you tried:

var_dump(get_defined_vars());

http://php.net/manual/en/function.var-dump.php

The php documentation should help.

Upvotes: 53

BugFinder
BugFinder

Reputation: 17858

You can make your own debug output, by iterating through the array of returned to display gettype, value and name. However, the where it was defined, how much its been used, you cant do. PHP doesnt work that way

Upvotes: 0

Related Questions