note 38812 added to function.popen

From: Date: Wed, 07 Jan 2004 17:47:43 +0000
Subject: note 38812 added to function.popen
Groups: php.notes 
Request: Send a blank email to php-notes+get-63091@lists.php.net to get a copy of this message
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?) ---- Manual Page -- http://www.php.net/manual/en/function.popen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38812 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38812&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38812&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63091) next »