php - Find the name of a calling var -
Anyone have an idea if this is possible with PHP?
function foo ($ Var) {// Here the code should be output to the value of the variable and should be the name of the variable when calling this function) $ hello = "World"; Foo (hello);
I have to give this output
varName = $ hello varValue = world
Since most people accuse me of bad behavior and global variable things, why am I going to expand this bit a bit more about why I am looking for this behavior.
P> What we are seeing on this kind of behavior is that we want to assign our scenes to extremes.Most of the time we are doing this to assign a variable to our view
$ this-> View- & gt; Assign ('product', $ product); $ This- & gt; View- & gt; Assign ('subscribers', $ members); Although
will be easy and more readable only to be able to do the following tasks and the data assigned due to the determination of this scene is in our thoughts.
$ this-> View-> Allocated ($ products); $ This- & gt; View-> Allocated ($ members);
This is also possible, despite my suspicions, how do I think a programmer The name of your variable is usually a bad idea. You have to answer questions like
$ arrProducts > Code> Can not name? If you want to keep the function's return value in view, you will also get a serious problem. Imagine the following code in which the category (for whatever reason) needs to be lowercase:
$ this-> View- & gt; Assign (stroller ($ range));
This will not work with what you are planning.
My answer therefore: Paste on the way you're working in Verbose
If you can not live with it, then You can still add to the view:
public function __set ($ name, $ value) {$ this- & gt; Assign ($ name, $ value); }
Then you
$ this-> view-> Products = $ the product can write;
Comments
Post a Comment