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?
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.
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.
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.
var_dump($this->_ci_cached_vars);
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