Thursday 1 August 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...