Click here to Skip to main content
11,490,292 members (52,175 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML PHP MySQL
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 4:14am
h4ckjr265
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 <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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 650
1 Andy Lanng 233
2 OriginalGriff 188
3 Sascha Lefèvre 170
4 Maciej Los 160
0 Sergey Alexandrovich Kryukov 9,713
1 OriginalGriff 8,475
2 Sascha Lefèvre 3,504
3 Maciej Los 3,106
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100