I had pages that contain duplicate codes. I wrote this line of code and used the query string to avoid repeating codes in every page:
$m=$_GET['m'];
$p=$_GET['p'];
include_once "$m/$p.php";
$m
is the directory that contains page $p
. page $p
is the content that must place in the non-fixed area of the main page. the main page is something like this:
<body>
<section id="container" class="">
<!--header start-->
<header class="header white-bg">
</header>
<aside>
<div id="sidebar" class="nav-collapse ">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
<li class="active">
<a class="" href="siturl?m=index&p=dashboard">
<i class="icon-dashboard"></i>
<span>dashboard</span>
</a>
</li>
</ul>
</div>
</aside>
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<?
$m=$_GET['m'];
$p=$_GET['p'];
include_once "$m/$p.php";
?>
</section>
<!--main content end-->
</section>
<script src="js/script1.js"></script>
<script src="js/script2.js"></script>
<script src="js/script3.js"></script>
</body>
after I click on the links on the sidebar who defined like this:
<a class="" href="siturl?m=index&p=dashboard">
<i class="icon-dashboard"></i>
<span>dashboard</span>
</a>
all scripts will be deleted despite they are out of the section that i placed content.