Re: Re: replacing variables in file
| From: | Paul Roberts | Date: | Sun, 12 Aug 2001 02:20:34 +0000 |
| Subject: | Re: Re: replacing variables in file | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62285@lists.php.net to get a copy of this message | ||
I want to read the include file in, replace the variables with any data
present and then send the included file to the browser between some header
and footer templates. I want the template to be straight html which can be
edited with a wysiwyg editor if required.
if I include the file as html I get errors as there are " and no valid
syntax I my php block ie no ;
i'd like to just do
$formdata = (include($filelocation));
but this returns 1 and pts it in the variable, I need the html form in the
variable.
----- Original Message -----
From: "CC Zona" <cczona@nospam.invalid>
To: <php-general@lists.php.net>
Sent: Sunday, August 12, 2001 1:35 AM
Subject: Re: [PHP] Re: replacing variables in file
| 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
|
| --
| PHP General Mailing List (http://www.php.net/)
| To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
| For additional commands, e-mail: php-general-help@lists.php.net
| To contact the list administrators, e-mail: php-list-admin@lists.php.net
|
|