<?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
dir() is a built-in function to store all the variables inside a program along with the built-in variable functions and methods. It creates a list of all declared and built-in variables. There are two different ways to view all defined variables using dir( ).
You can use ls() to list all variables that are created in the environment. Use ls() to display all variables.
As you might expect, printf can also print the values of variables. Here's an example: printf("The answer is %d\n", answer); The arguments to printf are a ``control'' string followed by the variables whose values you wish to print.
Have you tried:
var_dump(get_defined_vars());
http://php.net/manual/en/function.var-dump.php
The php documentation should help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With