Re: how do I use php://memory?

From: Date: Sat, 30 Jan 2010 06:57:40 +0000
Subject: Re: how do I use php://memory?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-301683@lists.php.net to get a copy of this message
On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote: > On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda <mari.masuda@stanford.edu> wrote: > Hello, > > I have a function that uses tidy to attempt to clean up a bunch of crappy HTML that I > inherited. In order to use tidy, I write the crappy HTML to a temporary file on disk, run tidy, and > extract and return the clean(er) HTML. The program itself works fine but with all of the disk > access, it runs quite slowly. > > why read from disk in the first place? > > http://us3.php.net/manual/en/tidy.parsestring.php > > -nathan Thank you, this looks like exactly what I need. Unfortunately I cannot get it to work on my machine. I recompiled PHP with --with-tidy=/usr/local and this is the version and modules in use: [Fri Jan 29 22:50:41] ~: php -vPHP 5.2.12 (cli) (built: Jan 29 2010 22:35:24) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies [Fri Jan 29 22:52:30] ~: php -m [PHP Modules] ctype date dom filter gd hash iconv json libxml mbstring mysql mysqli pcre PDO pdo_mysql pdo_sqlite posix Reflection session SimpleXML SPL SQLite standard tidy tokenizer xml xmlreader xmlwriter zlib [Zend Modules] [Fri Jan 29 22:52:34] ~: When I run this test code ===================== <?php $html = "<html><head><title>blah</title></head><body><p>hello</p></body></html>"; $config = array('indent' => true, 'wrap' => '0'); // Tidy $tidy = new tidy(); var_dump($tidy); $tidy->parseString($html, $config, 'utf8'); var_dump($tidy); $tidy->cleanRepair(); var_dump($tidy); echo tidy_get_output($tidy); var_dump($tidy); ?> ===================== I get this output: ===================== object(tidy)#1 (2) { ["errorBuffer"]=> NULL ["value"]=> NULL } object(tidy)#1 (2) { ["errorBuffer"]=> NULL ["value"]=> NULL } object(tidy)#1 (2) { ["errorBuffer"]=> NULL ["value"]=> NULL } object(tidy)#1 (2) { ["errorBuffer"]=> NULL ["value"]=> NULL } ==================== I have no clue what I'm doing wrong... Mari

« previous php.general (#301683) next »