Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing all defined variables and values

Tags:

<?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

like image 486
Vish Avatar asked Apr 03 '11 13:04

Vish


People also ask

How do I see all defined variables in Python?

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( ).

How can I see all variables?

You can use ls() to list all variables that are created in the environment. Use ls() to display all variables.

How do you print the value of a variable?

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.


1 Answers

Have you tried:

var_dump(get_defined_vars()); 

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

The php documentation should help.

like image 70
Steve Avatar answered Jan 18 '23 00:01

Steve