I'm trying to step through some PHP code that I did not write, and I have come to an impasse where I can't figure out how to continue.
I have reached as far as a class member function which looks like this:
public function exec($cmd, $args) {
// ... some argument checks here
$result = $this->$cmd($args);
What is this code doing? The value of $cmd is the string "info" so I assumed that it is calling the member function "info"... but when I put trace code at the top of that function, it is not producing any output.
I have also tried using var_dump($this->$cmd) but it prints NULL. Yet the function is being called and is returning a result, so maybe var_dump can't dump functions?
I have found another answer here which suggests that the above shouldn't work anyway. However, it definitely is assigning a complex value to $result which I am able to dump after the call returns.
If it matters, my trace code is below. I'm looking in the Apache error.log file, and it works fine everywhere else so I'm assuming the trace code is good:
$STDERR = fopen('php://stderr', 'w+');
ob_start();
var_dump($some_variable);
$result999 = ob_get_clean();
fwrite($STDERR, "TRACE: $result999\n");
fclose($STDERR);
Update:
I have also tried putting an empty return statement as the first line of the "info" function, but $result
still gets assigned the same value as before...