Page 2 of 2

Posted: Thu Jun 22, 2006 11:01 am
by RobertGonzalez
So you have a template that has a variable in it, and you are trying to fill the variable with the data that you want shown? Is that right?

Posted: Thu Jun 22, 2006 3:57 pm
by phelpsa
That is right. It is for an UltimaBB Forum.

Adam

Posted: Thu Jun 22, 2006 4:20 pm
by RobertGonzalez
What template system do they use for that BB? I only ask because in my template engines, you assign a variable a value, then when the template is parsed, that variable gets parsed with the template and the value assigned to that variable gets displayed. I'd like to see the parsing process.

Posted: Thu Jun 22, 2006 4:23 pm
by phelpsa
I'm not 100% sure but the templates are stored in the database and then pulled into the script by an eval() function. Make any sense to you? It's all a strange language to me! :lol:

Posted: Thu Jun 22, 2006 4:43 pm
by RobertGonzalez
It makes sense, though it seems somewhat insecure to use eval() on data coming from the database mixed with input coming from the script.

What you want to do is grab all of your data that belongs in your var ($myvar for example) up front by appending the var with the data.

Code: Select all

<?php
$myvar = '';

for ($i = 0; $i < 30; $i++)
{
    $delim = ($i == 29) ? '' : ' grows into ';
    $myvar .= $i . $delim;
}

echo $myvar;
?>
In this example, the $delim is not the important thing. What is important is the dot operator ('.') that is used before the equal sign ('='). What this does is append the string you are assigning to the end of what is already in the variable. This essentially lets you grow the string until you are ready to output it.