Mainly I use Rails for stuff on the web. But now I’m making a simple website and I’m using php for it. One of the things I really like about Rails is the use of a layout to keep pages consistent. I’m sure there’s a php framework I can use for this. But all I’m really want to do on my current site is have some static html pages loaded. I’m mainly using php to load the navigation bar. The one difference here is that I want the site to be responsive. So I’m using bootstrap for this. I want to make a function that lays everything out and then loads a specific page in the right place. Basically, I’m looking to recreate the Rails yield function.

I found one way to do it. (Though now that I’m thinking about it, I might do it slightly differently.)

First I create a php_functions.php file that I load onto each page. In the head I have this line:

<?php include_once '../php_functions.php'; ?>

This file has a function called show_page, which basically sets up all the divs and containers for the responsive design. And toward the bottom, it has this line, which is basically my yield.

<?php echo file_get_contents(substr($_SERVER['REQUEST_URI'],1,-1) . ".php") ?>

If I’m at a url of, it’s going to load a file called meetings.php at this spot. To me, this is logical and I’d have no problem with it. However, this is one website where someone else is going to be updating it. And while I don’t think that she’d have any problem figuring this out, I might want to make it more obvious. So I think when I call the show_page function, I should just put in the name of the file, as in:

<?php show_page('meetings.php'); ?>

I think that will make it more obvious which file she has to edit.