dealing with variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yshaf13
Forum Commoner
Posts: 72
Joined: Mon Apr 03, 2006 7:59 pm

dealing with variables

Post by yshaf13 »

hi, i am working on building a class that would generate html tables. my idea was to pass an array of 'column name' => 'column data' pairs where 'column data' would include html and php variables which were not yet created - they would be created only after the object was instantiated (loading them from a database...). my question is, how do i get variables in the array at first as a string and then later when the variables are actually created, parse them to get their values?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: dealing with variables

Post by Christopher »

Put the strings in sprintf format or use a templating system. Then you can pass the strings around and insert the value into the string at a later point. You might want to just look into a templating system, or use PHP as a templating system rather than your array of HTML scheme.
(#10850)
yshaf13
Forum Commoner
Posts: 72
Joined: Mon Apr 03, 2006 7:59 pm

Re: dealing with variables

Post by yshaf13 »

Thanks. i'M going to look into templating engines.Any simple ones that come to mind?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: dealing with variables

Post by Christopher »

I have seen people mention that they like TemplateLite several times in these forums.
(#10850)
Post Reply