I have a script that creates PHP files. These are then placed on my server. It is a bit complicated but I felt it was necessary because of some heavy database queries.
Anyway, now I want in some cases the output of this script go directly to the screens of my users. To do that I considered to replace the filename with something like STDOUT.
So I started with code like this (my simplified test case):
$fp = fopen("myfile.php", "w");
fwrite($fp, 'Hello <?php echo "world"; ?>');
fclose ($fp);
And then I replaced "myfile.php" with something like STDOUT. This had the following results:
- "php://stdout" no output
- "php://output" does give direct output but it does not process the embedded PHP. The user will only see "Hello" and if he looks at the source code in his browser it is followed by the original PHP code "<?php echo "world"; ?>"
- "STDOUT" errormessages: "fwrite() expects parameter 1 to be resource, string given"
Is there any way to get this a second time processed by PHP so that you see "Hello world" in the browser. Anyone an idea?
STDOUT problem
Moderator: General Moderators
- Ragnis
- Forum Commoner
- Posts: 31
- Joined: Thu Nov 13, 2008 12:35 pm
- Location: Saaremaa, Estonia, Europe, Asia, Planet Earth, The Solar System, Milky way.
Re: STDOUT problem
Use eval.
http://ee.php.net/eval
http://ee.php.net/eval