STDOUT problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
musicmaster
Forum Newbie
Posts: 1
Joined: Mon Jul 19, 2010 3:31 am

STDOUT problem

Post by musicmaster »

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?
User avatar
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

Post by Ragnis »

Post Reply