mardi 3 juillet 2018

Is there a way to get the name of the original variable name from the reference variable

I have this:

foo($Var1);
foo($Var2);

function foo(&$referenceVar)
{
    // 1. call: code which returns $Var1/Var1 from $referenceVar
    // 2. call: code which returns $Var2/Var2 from $referenceVar
}

My intention is to get the name of the original variable which was passed to foo(). So this code in foo() would evaluate the 1st time $Var1 or Var1 and the 2nd time it would be $Var2 or Var2

I know how to get the name referenceVar but this doesn't help me in my case.

My question:
How can I achieve this?





Aucun commentaire:

Enregistrer un commentaire