The aim of today was to use the process of PHP to create an individual file, in this case’ box’ so there is a lot less code but the process still works on the webpage. There was an introduction to the % which stands for modular operator.

Below is the end outcome in my index and then my box file.


<!doctype html>
<title>Format Code</title>
<link href=”css/styles.css” rel=”stylesheet” >

<div class=”container”>

<?php $title = “Box”; ?>

<?php $numberOfBoxes = 6; ?>

<?php include ‘nav.php’; ?>

<div class=”top-title”>
<h1><?php echo ‘Home Page – PHP’; ?></h1>

<div class=”clearfix”></div>

<?php while($numberOfBoxes > 0) { ?>

<?php include ‘box.php’ ?>

<?php $numberOfBoxes — ; ?>
<?php } ?>



<div class=”box <?php if (($numberOfBoxes % 3) == 1) { echo ” box-right”; } ?>”>
<h2><?php echo $title; ?></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam imperdiet varius blandit. Aliquam erat volutpat. Sed nisi mauris, pellentesque eu nibh in, tincidunt bibendum erat. Nullam et tincidunt dolor, non mollis velit.</p>
<img src=”images/beach-huts.jpg” />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s