How to link different section of webpage using PHP
![]() |
How to link different section of webpage using PHP |
In this tutorial, I show you how to link different section of webpage using PHP.
In other words, Inlcude header, menu,content and footer page into one page or single webpage.
Steps to link different section of webpage :
- First ,Create folder `php` in `www` directory.
- Create a new file, copy following code and save it as header.php .
<html>
<head>
<link rel="stylesheet" type="text/css" href="data.css" />
</head>
<body>
<div id="container" style="margin:0px auto;"><h1>
<div id="header"> <h1>This is header section</h1></div>
- Create a new file, copy following code and save it as menu.php.
<div id="menu"><h3>This is menu section</h3></div>
- Create a new file, copy following code and save it as content.php.
<div id="content"><h1>This is content section</h1></div>
- Create a new file, copy following code and save it as footer.php.
<div id="footer">This is footer section</div>
</div>
</body>
</html>
- Then, Create the CSS file and saved as data.css :
#container{height:1000px;width:1100px;margin:0pxauto,padding:0 px;background-color :black ;color:white;text-align:center;}
#header{height:150px;width:1100px;background-color:black;}
#menu{height:50px;width:1100px;background-color:red;}
#content{height:700px;width:1100px;background-color:black;}
#footer{height:100px;width:1100px;background-color:red;}
- At last ,Create the index.php file which is main file where all above files are included :
<?php
include('header.php');
include('menu.php');
include('content.php');
include('footer.php');
{[['
']]}
No comments