Skip to main content

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

 


Popular posts from this blog

Draw pyramid shape of stars in PHP using loop structure Write down the code in PHP using loop structure to draw the 3 pyramid shapes of stars as given bellow:

ravimanephpmysql

// problem 01 solution
for($i=5;$i>=1;$i--)
{
echo  str_repeat('*',$i);
echo "<br />";
}

echo "<hr />";

// problem 02 solution

for($i=1;$i<=5;$i++)
{
echo  str_repeat('*',$i);
echo "<br />";
}


echo "<hr />";
// problem 03 solution

$j=1;

for($i=5;$i>=1;$i--)
{
//echo  str_repeat("&nbsp;",$i-1);
echo  str_repeat('*',$j++);
echo "<br />";
}

Google reCAPTCHA with PHP tutorial

Login to your Google account and submit the form. Once submit, Google will provide you following two information. Site keySecret key

Integrate it into your website. To integrate it into your website you need to put it in client side as well as in Server side. In client HTML page you need to integrate this line before <HEAD> tag.
<script src='https://www.google.com/recaptcha/api.js'></script> And to show the widget into your form you need to put this below contact form, comment form etc.
<divclass="g-recaptcha" data-sitekey="== Your site Key =="></div> When the form get submit to Server, this script will send ‘g-recaptcha-response’ as a POST data. You need to verify it in order to see whether user has checked the Captcha or not. Simple comment form with Google reCAPTCH:Index.html <html>
<head>
<title>Google recapcha demo - Codeforgeek</title>
<scriptsrc='https://www.google.com/recaptcha/api.js'&g…

Simple Laravel CRUD with Resource Controllers

Creating, reading, updating, and deleting resources is used in pretty much every application. Laravel helps make the process easy using resource controllers. Resource Controllers can make life much easier and takes advantage of some cool Laravel routing techniques. Today, we'll go through the steps necessary to get a fully functioning CRUD application using resource controllers. For this tutorial, we will go through the process of having an admin panel to create, read, update, and delete (CRUD) a resource. Let's use nerds as our example. We will also make use of Eloquent ORM. This tutorial will walk us through: * Setting up the database and models * Creating the resource controller and its routes * Creating the necessary views * Explaining each method in a resource controller Table of ContentsGetting our Database ReadyEloquent Model for the NerdsCreating the ControllerSetting Up the RoutesThe ViewsMaking It All Work TogetherConclusion To get started, we will need the controll…