Split php content in multiple files

I have no idea if there is a technical term for this, so I did not find anything on Google and this site.

My friend, who has been creating websites for many years and actually creating a business, uses a rather unique (for me) system.

It splits its page into 3 parts, a headline, a body and a footer. Inserts them into 3 files, and then includes the header and footer on the body page, leaving only this: (example)

<?php   include_once "Constants/Header.php";    ?>

        <div id="Container">
            <div id="Header">
                HEADER
            </div>

            <div id="Menu">
                <ul id="Nav"> 
                    <li>Menu item</li>  
                    <li>Menu item</li> 
                    <li>Menu item</li>  
                    <li>Menu item</li> 
                    <li>Menu item</li>  
                    <li>Menu item</li> 
                </ul> 
            </div>

            <div id="Body">

            </div>
        </div>

<?php   include_once "Constants/Footer.php";    ?>

Is it good to code the site this way? So why? Last but not least, do you code your pages this way?

+5
source share
6 answers

, PHP . , , , , include , sitewide, ​​ Model-View- .
MVC, , (, , ..), . "" -, "" ( ), "" .
MVC, . . , " ", . - PHP, MVC, (, CodeIgniter).
, MVC " " - , . (-, ) include ( ) .

+4

( ) include PHP. , , , , .

, include.

+3

, , , .

, .

+2

, . 3 , , , (: index.php), , .

<?php
$active_page = $_GET['page'];
require_once('header.php');
require_once($active_page);
require_once('footer.php');
?>
+2

, PHP. , .

, .

+1

, .

, . , -, . , . script, - script. ( , , ).

, - , . . PHP. , , PHP-, PHP HTML .

PHP - - CMS. (, , , , ), CMS, Wordpress, Joomla, Drupal, DLE. - , , - PHP, MVC, Zend - ( ), CakePHP, CodeIgniter Symfony.

+1
source

All Articles