how to create template file in php. why it is usefull

ravimane and php,mysql
    that code that is same in two page no need to write twice , just make one file having that code and call or include anywhere you want.
    everyone have been trying with .tpl.php extension. but doesn't matter what you want take, but with .php extension. that cool na  .so check out below and seek whatever you want .
    below i made three file 
      
top.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css" type="text/css">
<meta name="Author" content="YOUR NAME HERE">

middle.php
</head>
<body>
<div id="banner">
<img src="xyzlogo.gif" alt="XYZ, Inc. logo">
</div>
<div id="menu">
<a href="index.php">Home</a> |
<a href="sitemap.php">Sitemap</a> |
<a href="products.php">Products</a> |
<a href="contact.php">Contact Us</a>
</div>

bottom.php
<div id="footer">
Last revised:
<?php
putenv("TZ=America/Los_Angeles");
echo date("m/d/y", filemtime($_SERVER["SCRIPT_FILENAME"]));
?>
</div>
</body>
</html>



now i am calling in single php file

 

 

template.php
<?php
include("includes/top.php");
?>
<meta name="Keywords" content="KEYWORD1, KEYWORD2, KEYWORD3">
<meta name="Description" content="BRIEF DESCRIPTION OF PAGE HERE.">
<title>Title here</title>
<?php
include("includes/middle.php");
?>
<div id="content">
CONTENT HERE
</div>
<?php
include("includes/bottom.php");
?>

easyna...so enjoy coding

 


Comments

Post a Comment

Popular posts from this blog

How can I debug PHP cURL sessions?

[PHP] Create MySQL Trigger in PHP

Free icons