Redirecting I/O in PHP
<pre><code>&lt;?php
    fclose(STDIN);
    fclose(STDOUT);
    fclose(STDERR);

    $STDIN = fopen("/tmp/some-named-pipe", "r");
    $STDOUT = fopen("/tmp/foo.out", "wb");
    $STDERR = fopen("/tmp/foo.err", "wb");

    echo "Hello, World!";                 // goes to /tmp/foo.out, implied STDOUT
    fscanf($STDIN, "%s\n", $top_secret);  // explicit $STDIN, cant use STDIN
?&gt;
</code></pre>

<p>Why is it that the redirection to the new STDOUT works implicitly, yet the redirection from the new STDIN must happen explicitly?</p>
