Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,926 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,809 people online right now. Registration is fast and FREE... Join Now!




Output buffer does not seem to work!

 
Reply to this topicStart new topic

Output buffer does not seem to work!

jnkrois
20 Mar, 2008 - 09:28 PM
Post #1

New D.I.C Head
*

Joined: 5 Mar, 2008
Posts: 3

Hello guys.

I've been struggling for a few days now with the "God Blessed" output buffer in PHP.

Basically what I want to do is have a script open up a file, read it and instead of echoing it to the browser, buffer it and write it to another file.

What follows is a very raw idea of what is on my mind:

CODE

<?php
ob_start();
$my_file = "test_file.html";
$my_other_file = "other_file.html";
$fp = fopen($my_file, "a+") or die("can't open file);
readfile("my_file");
$content = ob_get_contents();
fflush($my_other_file);
ob_end_flush();
fclose($fp);
?>


My apologies if the code above seems an abomination, I'm really taking PHP seriously but it's been challenging and I've looked all over the net and have not been able to find something in this regard that worked.

Thanks as usual for any help that I can get.
Jnkrois.

User is offlineProfile CardPM
+Quote Post

craig1709
RE: Output Buffer Does Not Seem To Work!
21 Mar, 2008 - 10:09 AM
Post #2

New D.I.C Head
*

Joined: 14 Jun, 2007
Posts: 18


My Contributions
php.net:
bool fflush ( resource $handle )
in this case $handle "must point to a file successfully opened by fopen() or fsockopen()" not a file name.

So you'd want $my_other_file = fopen("other_file.html");

That's the only problem I can see.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:24PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month