如何在PHP中的视图中获取所有可用的变量? [英] How to get all the variables available in a view in PHP?

查看:97
本文介绍了如何在PHP中的视图中获取所有可用的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要查看视图中提供的所有变量。我是一个前端开发人员,所以我主要工作在views目录。我不总是知道哪些变量被后端dev传递给模板。而不是每次一个简单的解决方案是一种简单的解决方案,我可以暂时粘贴到我正在工作的视图,所以我可以看到所有可用的变量,甚至更好,如果我还可以看到他们的类型和值。

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.

我尝试过:

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

但是因为我使用Codeigniter它还显示所有其他吨和吨的变量传递

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?

推荐答案

var_dump($this->_ci_cached_vars);

这篇关于如何在PHP中的视图中获取所有可用的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆