This exercise allows you to practice includes, conditional logic, comparison operators and control structures.
You are taking a static website and converting it to PHP. This will allow you to easily add pages and navigation by simply modifying PHP variables, instead of doing a find/replace on every page of your website.
- Clone or download this repository.
- In your terminal, enter the
php-website
directory. - Run
php -S localhost:8000
to start the local webserver.
- Visit http://localhost:8000/theme-src/ - This is the static HTML site. Use this for reference only.
- In a new tab, visit http://localhost:8000/www/index.php - This is your PHP version.
- Open
www/index.php
in your editor and includeconfig.php
at the top of your page. - Use includes to add each of the four partials where indicated.
- Open
www/_partials/header.php
and use aforeach
loop to output your navigation. - Use an
if
statement to add thecurrent
class to correct <li> tag. - Open
www/_partials/scripts.php
and use aforeach
loop to output your scripts. - Duplicate
index.php
asabout.php
andcontact.php
. - Change the content of
about.php
to resembletheme-src/left-sidebar.html
. - Change the content of
contact.php
to resembletheme-src/right-sidebar.html
.