有没有办法在PHP中重定向输出?

Is there a way to redirect the output behaviour of a php function like "echo" and make it so that it's new output when called anytime points to the file descriptor I provide?

There is. You can use output buffering.

http://php.net/ob_start

<?php

function callback($buffer)
{
  return $buffer;
}

ob_start("callback");

?>

Then when you echo anything, your callback() function will be called, and you can do whatever you want with the output.

You can redirect stdout to a file like this:

<?php

fclose(STDOUT);

$STDOUT=fopen('t.php.log', 'a');
echo "This is a test";

?>