David Beroff (d4b) wrote,
David Beroff
d4b

Include files

Yeah, yeah, I'm only a decade or two behind the cool kids, but I decided to (finally) start storing repetitive data for websites in single files. So, for a website that has multiple pages which essentially all look alike, I'm coding them as:
<?php $page = 'Sample'; ?>
<?php require 'includes/head.php'; ?>

<p>This page is "<?=$page?>".</p>

<?php require 'includes/foot.php'; ?>
And then for multiple sites which share common features, I'm having head.php include me.php, which sets some site-specific variables, so that head.php (et. al.) can do things like:
<title><?=$org_name?> | <?=$page?></title>
This'll save time and angst in the future, especially when things change. It's the little things that make me happy.
Tags: sak, webdev
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments