Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all the variables available in a view in PHP?

I need to see all the variables that are available in a view. I am a front end developer so I mostly work in the views directory. I don't always know which variables are being passed to the templates by the back end dev. Instead of asking him every time an easy solution would be some type of snippet that I can temporarily paste into the view that I'm working on so I can see all the available variables and even better if I can also see their types and values.

I tried this:

<pre><?php var_dump(get_defined_vars()); ?></pre> 

But since I am using Codeigniter it also shows all the other tons and tons of variables that are passed in by the framework.

I only want to display the variables that were passed specifically from the controller that loaded the view. Is there any way to do this?

like image 423
Sam Avatar asked Aug 27 '11 23:08

Sam


People also ask

How can I get all post variables in PHP?

Try var_dump($_POST); to see the contents. If your post data is in another format (e.g. JSON or XML, you can do something like this: $post = file_get_contents('php://input'); and $post will contain the raw data.

How view variables in php?

PHP | get_defined_vars() Function The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc.

How many types of variables are there in PHP?

PHP has eight diffrent types of values or datatypes. The first five are basic: integers, floating-point, string, booleans, null. Two other are composed of the basic types or composite types. They include arrays and objects.


1 Answers

var_dump($this->_ci_cached_vars); 
like image 52
Vikk Avatar answered Oct 12 '22 05:10

Vikk