Skip to main content

How to Upgrade Your RAM and SSD on Ubuntu: A Complete Guide 2025 - 2026 midway

master page in php

Simple MasterPages with PHP
If you are an ASP.Net developer used to working with MasterPages (or any equivalant on another framework), you may be looking for an equivalant while working with php.  I was looking to do something like that with my homepage (hoolihan.net).  This is a very simple site, where a full framework would have been overkill.
Here’s how I pieced it out:
First: Create a template page, I called mine master.php.
<body>
<div><?php include('header.php');?></div>
<div><?php include('menu.php');?></div>
<div><?php include($page_content);?></div>
<div><?php include('footer.php');?></div>
</body>


Second: Create a content piece, for example about_text.php.
<p>This is information about me.</p>
Third: Create the page with the actual name you want to use:
<?php
$page_content = 'about_text.php';
include('master.php');
?>


<?php
$page_content = 'about_text.php';
include('master.php');
?>

save ->  about.php

One added benefit is that the content piece is then loadable in other places if need be.
Obviously, you’ll want to add a few bells and whistles.   For example, It’s a good idea to check for $page_content being null, and provide a default in that case.  I left out some of those things for the sake of brevity.
For more patterns in php, check out the following books:
PHP Objects, Patterns and Practice (Expert’s Voice in Open Source)
PHP Object-Oriented Solutions
Basically, it’s a real simple way to cleanly break up your php pages.  Hope you found  this useful…
Update: I’ve posted a follow-up article about the ajax ideas mentioned in this article. Also, see more php posts on this blog and more programming posts.
Update 2: User Ton posted a good comment below about how to setup the content variable (and simplify your url) with apache.

Comments

Popular posts from this blog

Shopify fully custom contact section block on home page

Tech Easy Solutions Shopify fully custom contact section block on home page <section class="contact-information" >       <!--<div class="left-shape">         <img src="images/left-shape.png" class="img-fluid">       </div>-->       <div class="container c-container">         <div class="row">           <div class="col-lg-6 col-md-6 col-sm-12 col-12">             <div class=" contact-us">                         {% form 'contact' %}                       {% if form.posted_successfully? %}                        <center> <p class="note form-success">                   ...

How to delete Torrent power account

Sanjay Tech solutions 3 easy tips to delete torrent power account  Step 1 : login in to your account Step 2 : click on more profile settings Step 3 : you see red button with deactivate account click then enter your password Your account deactivate 

Fixing PHP 8.2 zip Extension Error on Ubuntu 25 for Laravel 10,11,12 Shopify Apps

Tech Easy Solutions           Solution : How to Fix PHP 8.2 zip Extension Error on Ubuntu 25 Since Ubuntu 25’s PPAs don’t yet support this extension directly, there are three approaches to fix this: server  / local Ubuntu   Compile the Zip Extension from Source (Recommended) Install development packages: $ sudo apt-get install php8.2-dev libzip-dev build-essential unzip Install the zip extension via PECL:  $ sudo pecl install zip Enable the extension:  $ echo "extension=zip.so" | sudo tee /etc/php/8.2/cli/conf.d/20-zip.ini $ echo "extension=zip.so" | sudo tee /etc/php/8.2/fpm/conf.d/20-zip.ini Restart PHP services : $ sudo systemctl restart php8.2-fpm Verify $ :  php -m | grep zip ____________________________________________________ Result :  Error tracer : Why This Error Happens When running a Laravel 12 Shopify project on Ubuntu 25, you might see an error like: php8 .2 - zip : Depends: libzip4t64 (>= 1....