note 38812 rejected from function.popen by nlopess
| From: | nlopess@php.net | Date: | Wed, 07 Jan 2004 19:10:28 +0000 |
| Subject: | note 38812 rejected from function.popen by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-63096@lists.php.net to get a copy of this message | ||
Note Submitter: The Otter
----
Ran into a problem... Someone under the Output Functions section recommended the following code to
run pages through HTML-Tidy:
<?php
ob_start();
?>
Content here
<?php
$str=addslashes(ob_get_contents());
$fp=popen("echo \"" . $str . "\" | /usr/bin/tidy -i -u -q -latin1
--indent-spaces 1 -wrap 0", "r");
@$newstr=fread($fp, 99999);
ob_end_clean();
Header( "Content-length: " . strlen( $newstr ) );
echo $newstr;
?>
You must watch the length of your pages. I have a main template page on my site that would use this
on every page. It worked fine for home page, but when I got to a large table (138 KB), I got no
output. I assume this exceeded the built-in Linux limit on program command-line argument size (1
memory page is it?). I am working on a workaround right now. (Use temporary files?)