I’m having trouble understand how exactly INCLUDE statements work.
For example, let’s say i have a file, index.htm and a file data.php
Index.htm
<div id="1">
contentcontentcontentcontent
</div>
<div id="2">
<?php include 'data.php' ?>
</div>
So my question is, does div 2 contain the entirety of data.php? Like, what if data.php has divs and spans of its own? Does div 2 act as a mini page (kind of like a frame) where its contents are displayed only within the parameters of its div?
Also if i apply css style to div 2 to make it 200×200 pixels in the centre of the screen, does that mean that data.php will be displayed exactly there, and only within that 200×200 space?
The point of the php include is to allow you to separate your project into smaller sections and reuse code where applicable.
Yes, whatever is in the file
data.phpwill be placed inside ofdiv#2.Yes so long as the data does not overflow your container.
A practical example of using an include would be to separate the html that is used to create your menu. Then in each of your pages you can include the menu file. Now if you need to make changes to your menu you only have to update one file.