Maybe I'm misunderstanding something. I'm suggesting that you not bother at
all with an ereg_replace system.
If you want to do a system like you're suggesting, you would use a variable
variable. That is, ${$var} will evaluate to 'Hello' when $var = 'title' and
$title = 'Hello'.
HTH,
Julian
on 1/27/01 6:56 PM, Zack Ham at [EMAIL PROTECTED] wrote:
>
> I had it echo off the value of $var right before it ran the ereg_replace and
> it echoed "TITLE". So there is a value... any ideas on fixing?
>
> --- Julian Wood <[EMAIL PROTECTED]>
>> wrote:
>>
>> Why not use the php mechanism itself? An easy way to do a template system is
>> make a normal php page as a template, and then include it from another page
>> after specifying a bunch of variables.
>>
>> eg.
>>
>> template.php:
>> =========
>>
>> <html><head><title><?= $title ?></title></head></html>
>>
>> calling page:
>> =============
>>
>> <?php
>>
>> $title = "My template system";
>> include ('template.php');
>>
>> ?>
>>
>> Hope this helps,
>>
>> Julian
>>
>> on 1/27/01 6:17 PM, Zack Ham at [EMAIL PROTECTED] wrote:
>>
>>>
>>> I'm trying to create a small template parser so I can fill my html pages up
>>> with data. An example: <html><head><title>{title}</title></head></html
>>>
>>> What I'm trying to do is run through it and replace {title} with an
>>> appropriate value. I have tried running
>>> ereg_replace("{$var}",$value,$string)
>>> and ereg_replace("\{$var\}",$value,$string). Neither work. They either do
>>> nothing or produce the error "Warning: invalid content of \{\}".
>>>
>>> Any help would be appreciated,
>>> Zack
>>>
>>> _____________________________________________________________
>>> Free email provided by ---> http://sect0r.com
>>
>> --
>> Julian Wood
>> Learning Technologies and Digital Media
>> University of Calgary
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> _____________________________________________________________
> Free email provided by ---> http://sect0r.com
--
Julian Wood
Learning Technologies and Digital Media
University of Calgary
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]