note 76339 added to function.eval

From: Date: Wed, 11 Jul 2007 10:56:42 +0000
Subject: note 76339 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-128376@lists.php.net to get a copy of this message
Ever whished to evaluate an external file as a PHP script and get the result as string? Exemple: you'd like to get the contents (and all PHP output) of a (text|XML|HTML) file after having processed whatever PHP inclusion it may contain, to further process these contents. You can do this: <?php $str = compile('file_to_process'); $str = do_more_things_with($str); echo $str; function compile($file) { ob_start(); require $file; return ob_get_clean(); } ?> It *should* work without problem if the caller script already uses output buffering, since output buffers are stackable (not tested yet). ---- Server IP: 217.174.196.197 Probable Submitter: 90.31.46.253 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- https://master.php.net/note/edit/76339 Del: integrated -- https://master.php.net/note/delete/76339/integrated Del: useless -- https://master.php.net/note/delete/76339/useless Del: bad code -- https://master.php.net/note/delete/76339/bad+code Del: spam -- https://master.php.net/note/delete/76339/spam Del: non-english -- https://master.php.net/note/delete/76339/non-english Del: in docs -- https://master.php.net/note/delete/76339/in+docs Del: other reasons-- https://master.php.net/note/delete/76339 Reject -- https://master.php.net/note/reject/76339 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128376) next »