Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTMLPHPMySQL
At some HTML source file i get some code like this
<html>
 <head>..</head>
 <body>
  <div id="header">
   <img src="{{companyLogo}}"/>
   <p id="companyName">{{companyName}}</p>
  </div>
  ...... <!-- and many {{...}} tag -->
 </body>
</html>
 
the
{{companyName}} and {{companyLogo}}
This tag is output from database like
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 23-Sep-12 3:14am
h4ckjr250
Comments
Mohibur Rashid at 23-Sep-12 10:53am
   
what framework are you using with php?
h4ckjr at 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.
nK0de at 23-Sep-12 10:56am
   
what is this {{}} tag? I've never seen it.
SamarRizvi at 23-Sep-12 16:09pm
   
Why do you want to use a tag {{..}} like this?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There is no such tag as "{{}}".
But it can be done something like this example:
<?
// 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;
?>
  Permalink  
v2
Comments
h4ckjr at 25-Sep-12 3:04am
   
Hi Huseyin thanks for the solution. :) I think the {{}} is custom tag that define constant in php.
Huseyin Atasoy at 25-Sep-12 4:21am
   
You can use anything that you want instead of {{}}. For example you can write &lt;myvalue&gt; 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)

  Print Answers RSS
0 Dnyaneshwar@Pune 994
1 Sergey Alexandrovich Kryukov 826
2 OriginalGriff 448
3 Tadit Dash 390
4 sanket saxena 323
0 Sergey Alexandrovich Kryukov 11,800
1 OriginalGriff 7,225
2 Peter Leow 5,009
3 Abhinav S 3,893
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid