How Can I get the string that present the variable in function argument?
example
function dbg($param){
return "param";
}
$var="Hello World";
echo dgb($var);
output: var
$arr=array();
echo dgb($arr);
output: arr
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is NOT possible to do what you ask reliably.
The closest you can come up to doing that is to do a
debug_backtrace()to check which file called the function then tokenize the source of that file to find the reference.Again, this will not work reliably. It will fail if you have multiple calls on one line. Truthfully, it isn’t work the trouble. You are writing the code anyway, you know which variable you are passing.