Click here to Skip to main content
15,896,498 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
At some HTML source file i get some code like this
HTML
<html>
 <head>..</head>
 <body>
  <div id="header">
   <img src="{{companyLogo}}"/>
   <p id="companyName">{{companyName}}</p>
  </div>
  ...... <!-- and many {{...}} tag -->
 </body>
</html>


the
HTML
{{companyName}} and {{companyLogo}}
This tag is output from database like
PHP
echo $companyName;
in PHP.
My question is how it can display data from database? because it's just .html file.
There are no special tag except the {{..}} tag.
Is there any php framework that similar to use {{..}} tag ?

Many thanks for share the answer.
Posted
Comments
Mohibur Rashid 23-Sep-12 10:53am    
what framework are you using with php?
h4ckjr 24-Sep-12 0:10am    
I don't know what is the php framework.
I just make a template for this web using HTML and CSS from PSD document, and then i have to replace the content with {{..}} such as {{companyName}} and others.

Isuru Nanayakkara 23-Sep-12 10:56am    
what is this {{}} tag? I've never seen it.
SamarRizvi 23-Sep-12 16:09pm    
Why do you want to use a tag {{..}} like this?

1 solution

There is no such tag as "{{}}".
But it can be done something like this example:
PHP
<?
// These can be read from a database
$companyName = "Name";
$companyLogo = "Logo Url";

//$html = file_get_contents("file.html");
$html = "...{{companyName}} and {{companyLogo}}...";

$tags = array('{{companyName}}' , '{{companyLogo}}');
$values = array($companyName, $companyLogo);

$replaced = str_replace($tags,$values,$html);

echo $replaced;
?>
 
Share this answer
 
v2
Comments
h4ckjr 25-Sep-12 3:04am    
Hi Huseyin thanks for the solution. :)
I think the {{}} is custom tag that define constant in php.
Huseyin Atasoy 25-Sep-12 4:21am    
You can use anything that you want instead of {{}}. For example you can write <myvalue> or valMYVALUEval. We do that just to make them unique in a html page to prevent real contents from being replaced and making it easy to understand that they will be replaced.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900