Re: [PHP4BETA] Include vs exec

From: Date: Tue, 04 Jan 2000 03:53:37 +0000
Subject: Re: [PHP4BETA] Include vs exec
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-8890@lists.php.net to get a copy of this message
Ps just for clarity, (it is past 4am here ;/) what im looking to do is basicly a include on a $string instead of a file name, thus loading the string directly into the php parser, and skiping the file save's/load's... this way one could do $title = "dummy"; $s = "<html><head><title><? echo "$title"; ?></title></head></html>"; string_include($s); Chris Chabot wrote: > Ive recently run into what seems to be a limitation of PhP while implimenting > a templating engine. > the 2 functionalities im trying to combine are: > filter key frazes (eg replace @title@ by 'This is a title') > allow php execution (eg allow <? echo 'a'; ?>) > these 2 specs seem to be hard to combine. If i had just the ereg_replace, i > could load the template (html file) into mem, parse the @var@'s, and echo the > result to stdout. Also if i just wanted to do php execution i would read the > (php) file into memory and call exec("$template") > but how do i do a combination of both? all i can think of is read the > template file containing both php code and html into memory, ereg_replace the > @var@'s, write the output to a temp file, and then include($file) the thing. > This however would kill performance, and thus it wouldnt be a very nice > solution for me. Also this would limit my potential expantions. I'd like to > be able to use sysv shared mem for this engine one day, and read the template > into shared memory, and load it from there on every calling of the page, this > would save me a lot of sql and/or file calls, thus cutting down stackswitches > and system time dramaticly > > (eg flow would be: > if (on first read, or template update) then (read 'file/sql blob' into > sysv shmem) > > load template from shmem into $template > parse @var@'s in the $template string (ereg_replace on string) > 'include' (read include functionality: exec + echo) the $template string > (call strinclude($template)?). > ) > > i hope this is a limitation we can easely overcome, and it would definaly > make my life a lot easier! > > -- Chris Chabot > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net

« previous php.version4 (#8890) next »