qbox Posted May 16, 2008 Share Posted May 16, 2008 Hi to all This is my first post on this forum. I have one php code before me and I cant figure out why there is used things like {SOME_TEXT} and how they work, how to define and stuff. Here is example: <div align="center">{_TOTAL_NUMBERS} <font class="red"> <input name="submit" type="submit" class="submit" value="{_BTN_GO}" /> ...................... And this is used in .html file There is a .php files but I cant figure out how this in {} worked. ??? Thanks Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted May 16, 2008 Share Posted May 16, 2008 the {} let you add in variables inside there to echo out with the HTML example: <?php $variable = "test"; echo <<<HTML <div> <p>This is a {$variable}</p> </div> HTML; ?> and _TOTAL_NUMBERS must have been defined somewhere example: <?php define("_TOTAL_NUMBERS", 28); echo <<<HTML <div> <p>Your Total Number Is: {_TOTAL_NUMBERS}</p> </div> HTML; ?> the define() function sets things just like variables do except its a constant instead of a variable. read this: http://php.net/define Quote Link to comment Share on other sites More sharing options...
trq Posted May 16, 2008 Share Posted May 16, 2008 Hi to all This is my first post on this forum. I have one php code before me and I cant figure out why there is used things like {SOME_TEXT} and how they work, how to define and stuff. Here is example: <div align="center">{_TOTAL_NUMBERS} <font class="red"> <input name="submit" type="submit" class="submit" value="{_BTN_GO}" /> ...................... And this is used in .html file There is a .php files but I cant figure out how this in {} worked. ??? Thanks None of the code you have posted is actually php but likely a template file used by a php template engine to create html. Consider this very simple example..... template.html <html> <head> <title>{TITLE}</title> </head> <body> <h1>{HEADING}</h1> <p>{CONTENT}</p> </body> </html> engine.php <?php $data = array('TITLE' => 'foo', 'HEADING' => 'this is foo', 'CONTENT' => 'this the story of foo'); $template = file_get_contents('template.html'); foreach ($data as $k => $v) { $template = str_replace('{' . $k . '}', $v, $template); } echo $template; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.