Modular Websites

aa thisis

What is PHP?

PHP is similar to a lot of other programing languages. What sets it apart is the ability to seamlessly integrate into HTML. The name PHP is a recursive acronym for PHP: Hypertext Preprocessor (though it originally derived from Personal Home Page Tools). That tells you that PHP, which resides on the server, creates HTML files from PHP scripts on the fly.

As an end user, all you see are HTML pages, so PHP does its work behind the scenes on the server from which you request the page. This is different from Javascript, for example, which is executed by the browser on the page as it is served. The PHP constructs the page before javascript can act on it.

What we will do in this section, after briefly talking about some details of how PHP actually works, is show how PHP can modularize web development.

Modular Web Development

One way to think about a web site is as a collection of pages, which is what we have done up to now. CSS helps us reduce redundancy by centralizing the instructions of what each page is to look like. A centralized style sheet saves us a lot of time. PHP allows us to do the same for the different parts of the web site that stay the same from page to page.

A web page is composed up of modules that remain pretty consistent throughout the site, like the header, navigation, asides, footer, etc. PHP allows us to separate these modules out as centralized external files. That means we will be creating modules like footer, header and navigation, and then use PHP to put them all together and serve them up as finished HTML pages.