lundi 11 janvier 2021

Is it possible to retrieve the expression provided to a functions parameter as a string?

I would like to be able to write a function like:

function f($a, $b) {
  $ax = caller_expression($a);
  $bx = caller_expression($b);

  echo "$ax, $bx";
}

When I call it like so:

f($object->prop, 2 + 2);

I would like the output to be:

$object->prop, 2 + 2

Can this be done?





Aucun commentaire:

Enregistrer un commentaire