How to use {} instead of opening PHP tags?

Asked

Viewed 111 times

3

I see in various Muonline sites, as well as in others, I see the staff use instead of <? SERVER_NAME; ?> they use {#SERVER_NAME}, without opening PHP tags.

Instead of using <? include("menuLeft.php"); ?> they use {#INCLUDE:menuLeft}.

I don’t understand anything, can anyone tell me how I do it too?

  • 1

    Probably almost the same as my previous question about % in html, this is probably some template system http://answall.com/questions/76192/uses%C3%A7%C3%A3o-de-em-arquivos-html

  • 1

    I noticed that you do not mark the answers "as correct", to mark them as correct, on the side of each answer has a drawing similar to this - click on what the answer was that helped you. Note that no response has been checked yet: http://answall.com/users/19903/edward-junior?tab=questions

1 answer

6

Probably the views of this site are using Smarty.

He is a template engine under the table converts the file to PHP markup from the simplified syntax used by it.

See one example using PHP and another using Smarty syntax

In PHP:

<?php if(!empty($foo)): ?>
  <?php foreach($foo as $bar): ?>
     <a href="<?=$bar['zig']?>"><?=$bar['zag']?></a>
     <a href="<?=$bar['zig2']?>"><?=$bar['zag2']?></a> 
     <a href="<?=$bar['zig3']?>"><?=$bar['zag3']?></a> 
  <?php endforeach; ?>
<?php else: ?>
   There were no rows found.
<?php endif; ?>

Smarty:

{foreach $foo as $bar}
  <a href="{$bar.zig}">{$bar.zag}</a>
  <a href="{$bar.zig2}">{$bar.zag2}</a>
  <a href="{$bar.zig3}">{$bar.zag3}</a>
{foreachelse}
  There were no rows found.
{/foreach}

Besides Smarty, there are others template Engines for PHP. Their purpose is the same: to simplify the syntax of templates with PHP. The difference between them is basically syntax and one feature or another:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.