Re: Problem with a regex!

From: Date: Sun, 28 Jan 2001 02:21:47 +0000
Subject: Re: Problem with a regex!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37075@lists.php.net to get a copy of this message
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 hamoe@sect0r.com 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 <woodj@ucalgary.ca> >> 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 hamoe@sect0r.com 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: 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 > > _____________________________________________________________ > Free email provided by ---> http://sect0r.com -- Julian Wood Learning Technologies and Digital Media University of Calgary

« previous php.general (#37075) next »