What is the equivalent to Master Views from ASP.NET in PHP?

Posted by KingNestor on Stack Overflow See other posts from Stack Overflow or by KingNestor
Published on 2009-11-19T23:51:51Z Indexed on 2010/04/13 16:03 UTC
Read the original article Hit count: 275

Filed under:
|
|

I'm used to working in ASP.NET / ASP.NET MVC and now for class I have to make a PHP website.

What is the equivalent to Master Views from ASP.NET in the PHP world?

Ideally I would like to be able to define a page layout with something like:

Master.php

<html>
    <head>
        <title>My WebSite</title>
        <?php headcontent?>
    </head>
    <body>
        <?php bodycontent?>
    </body>
</html>

and then have my other PHP pages inherit from Master, so I can insert into those predefined places.

Is this possible in PHP?

Right now I have the top half of my page defined as "Header.html" and the bottom half is "footer.html" and I include_once both of them on each page I create. However, this isn't ideal for when I want to be able to insert into multiple places on my master page such as being able to insert content into the head.

Can someone skilled in PHP point me in the right direction?

© Stack Overflow or respective owner

Related posts about php

Related posts about asp.net-mvc