note 85557 added to function.include

From: Date: Fri, 05 Sep 2008 21:59:18 +0000
Subject: note 85557 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-144172@lists.php.net to get a copy of this message
I have another function implementation of the include_text, that works better but makes use of the filesystem... Here it is : <?php function include_text($__text,$__exported){ foreach($__exported as $__name => $__value) { $$__name = $__value; } $__filename = tempnam('/tmp/','Form'); file_put_contents($__filename,$__text); ob_start(); include $__filename; $__contents = ob_get_contents(); ob_end_clean(); unlink($__filename); return $__contents; } ?> Usage example (the code speaks for itself) : <?php // .... $exportedVars['Names'] = $Names; $exportedVars['Data'] = $Data; $includedResult = include_text($importedText,$exportedVars); echo $includedResult; // Or make anything you want with it // .... ?> Note : it works nicely but doesn't return the exported vars if they are changed. I didn't neede that, so figure it out yourself if you need it (and share it !) ---- Server IP: 217.174.223.124 Probable Submitter: 82.235.64.74 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/85557 Del: integrated -- https://master.php.net/note/delete/85557/integrated Del: useless -- https://master.php.net/note/delete/85557/useless Del: bad code -- https://master.php.net/note/delete/85557/bad+code Del: spam -- https://master.php.net/note/delete/85557/spam Del: non-english -- https://master.php.net/note/delete/85557/non-english Del: in docs -- https://master.php.net/note/delete/85557/in+docs Del: other reasons-- https://master.php.net/note/delete/85557 Reject -- https://master.php.net/note/reject/85557 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144172) next »