You can’t do this and there’s no reason to do it.
Actually, there might be a way. I don’t know one specifically but since PHP is a basically interpreted language, it is possible that there is an API that allows you to access this information, or in the last case you could try to load your own source script, analyze it and find to inform. But it is not something simple and it would be ridiculous to do this.
If it’s just curiosity, she’s satisfied. If you really want to use this for something real, rethink your design, something very wrong is being done.
What you want to do is easy to solve, just create a parameter with the name of the variable passed. I know you want to avoid this, but there’s a reason variables have scope and what you’re trying to do is just go over it. Functions were made to be independent, not need to know anything of what was used to call it.
And this has another problem, you’re looking for information that may not even exist. I’ve talked in some places that people get confused with variables and expressions. An argument from a function call asks for an expression and not a variable. If this expression is only a variable, this is just a coincidence. What is the variable name if you call it:
function pessoa() {
ve(array(
'nome' => 'Guilherme',
'sobrenome' => 'Lautert'
), 1);
}
I put in the Github for future reference.
That is, you want information that is not even the argument of the function. You have to go further to get it. And how far you have to go?
The simplest you can get is the name of the parameter, but you already know how to get it. And actually it doesn’t need to, you already know what it is when you’re coding. It’s not variable at runtime.
Difference between argument and parameter.
Another solution is to make the variable global, but please do not do this under any circumstances.
Again I do not understand the -1 of the question.
– Jorge B.