Re: Re: replacing variables in file

From: Date: Sun, 12 Aug 2001 00:35:35 +0000
Subject: Re: Re: replacing variables in file
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-62282@lists.php.net to get a copy of this message
In article <000001c122b9$e055d460$7763883e@portable1>, roberts_paul@bigfoot.com (Paul Roberts) wrote: > | $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 Like I said before: "See <http://php.net/include> for more info." There's a wealth of useful info there (for example, note that if the included file returns a value, that value can be captured into a variable, like "$myvar=include($filelocation);"). If there's something in those docs that you need clarification on, do post again. > 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. Perhaps if you explained what differences you expected to get from these two lines...? (Looks to me like you *want* to dump the template file right at that point. What errors specifically is PHP reporting?) > 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; See <http://php.net/foreach> and <http://php.net/preg-replace>. -- CC

« previous php.general (#62282) next »