The Basics of Web Development: Part II

This article is a sequel to the previous one; here I intend to give a brief explanation of what PHP is used for to maybe help you decide whether you want to jump into it. I will be covering JavaScript in my next article of the series. 

PHP

File extension: .php

PHP stands for Hypertext Preprocessor (originally, Personal HomePage). To get a better understanding of what PHP really is, allow me to start with more abstract terminology. When we talk about Web development, there are two major groups programming languages can be divided into: client side and sever side languages. The difference between the two is in the way the code is executed.

Client-side languages are executed on the (weirdly enough) client side, which is the end user, which is the browser you're using to surf the Internet. The most famous client-side language we all have heard about is JavaScript; on a side note, JavaScript has nothing to do with Java. All JavaScript commands and instructions are run by the browser (let's not perplex ourselves with server-side JavaScript). It means that if we write a piece of JavaScript code, it will be executed by Google Chrome in one case, by Mozilla Firefox in another, and so on.  

The situation is different with server-side languages like PHP. Your website is always kept on a server, a powerful computer specifically designed for the purpose of storing websites. All commands and scripts written in PHP are executed on the server, and there are no exceptions to the concept. When a PHP script has finished running on the server, the server sends the resulting “work” to the browser, which in its turn transforms it into the human-readable form.  

This means that by just looking at the source code of a page(for example, by right clicking on a page and choosing “View page source”), you won't be able to spot what's been written in PHP, because all you will see will be the good oldHTML code.

PHP CodePHP Code

As opposed to plain HTML, pages with PHP code go through two (instead of one) stages: first, a so-called “interpreter” runs your PHP code (which turns it into plain HTML), and then the browser displays it in accordance with certain rules (go back to my previous article if you forgot how it works).

Why would one want to use PHP? Well, plain HTML is static. By adding PHP code to your page, you can make its contents to be displayed differently depending on certain conditions (in other words, make your page dynamic).  

To start working with PHP, you'll need a couple of things:

  1. An Apache web server (used in most cases). Its purpose is to imitate the server (where your website will be stored) on your PC. Basically, you need it to test PHP code you're writing, or, in other words, you need it for debugging.

  2. A relational database management system (RDBMS), e.g. MySQL. That's where the data/content will be stored.

  3. A PHP interpreter – it's a kind of a program that processes PHP code on a web server. Without it, we can't run our code and see the result of running it.

  4. A text editor where you will be writing the code.

  5. A browser

To sum it up, PHP allows us to implement a certain “behavior” for our website, thus providing us with an opportunity to create truly rich and powerful websites.

Comments