Wow. 6 minutes for a response. Of course, I thought my error was in the popen(), not fread(), so I didn't even check there. I've just fixed the code, and it works! Thanks, Philip.
On Jun 8, 2003, "Philip Olson" claimed that: | |PHP 4.3.0-1 has a bug that made your previous code "work", |have a look at the fread() docs for why, here's a quote: | | "Note: When reading from network streams or pipes, such | as those returned when reading remote files or from | popen() and proc_open(), reading will stop after a packet | is available. This means that you should collect the data | together in chunks as shown in the example below." | |It goes on to show that you must loop threw it to get |fread() to do what you want in the below code. Although, |the example it eludes to is wrong (a correct example will |show when the manual next builds), you get the point... :) | |Regards, |Philip | | |On Sat, 7 Jun 2003, Jeff Harris wrote: | |> My webhost just upgraded to php 4.3.2, and now I have a problem with |> popen. I'm opening an output buffer then piping it through htmltidy to |> make nice looking output. |> |> <?php |> ob_start(); |> // Other unimportant coding goes here |> |> $str=addslashes(ob_get_contents()); |> $fp=popen("echo \"" . $str . "\" | /bin/tidy - config /my/home/htmlrc", "r"); |> @$newstr=fread($fp, 999999); |> ob_end_clean(); |> header("Last-Modified: " . $gmt_modtime); |> header( "Content-length: " . strlen( $newstr ) ); |> echo stripslashes($newstr); |> ?> |> |> |> This code worked perfectly before the upgrade, now "strlen( $newstr )" is |> only getting back 4096 bytes. Is anybody else having this issue, and how |> can I fix this? I don't see any configuration setting that looks like it |> fits to this situation. It is running under redhat with Apache/1.3.27 |> |> Thanks, Jeff |> -- -- Registered Linux user #304026. "lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import" Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php