Re: Re: replacing variables in file

From: Date: Sat, 11 Aug 2001 19:23:28 +0000
Subject: Re: Re: replacing variables in file
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-62278@lists.php.net to get a copy of this message
| | $template="/path/to/somefile.inc"; | include($template); | | The variable substitution happens automatically (as long as $var occurs | within proper PHP syntax, such as "<?php $myvar1 ?>"). Output to browser | is also automatic. See <http://php.net/include> for more info. | I tried this print (include($filelocation)); returns true and prints 1 include($filelocation)); causes the template file to be dumped into the middle of the script causing errors. I want to have a form template with some of the data pre- filled from another form and print this between a header and a footer. at the moment I have got it to work having $formdata=" at the top of the form template and all the " escaped, but I would have rather had the form template editable without having to mess around. if I could get to work as in Perl I'd be happy, is there an equivalent of $1 in php foreach $item (@template) { $item =~s/\$(\w+)/${$1}/g; Paul Roberts roberts_paul@bigfoot.com +++++++++++++++++++++

« previous php.general (#62278) next »