Thursday, August 1, 2019

PHP: Get name of variable passed as argument







problem



Sometimes, I need to to show name of variable passed as argument while debugging, can I get a name of var passed to function if it exists and value if it doesn't?




example



function foo($bar){
print_variable_name($bar); //<- this part baffles me
}

foo ("Pure string."); //output " Pure string. "
foo ($argumentvariable); //output " argumentvariable "



solution

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...