About PHP

All Custom Websites Created by Gradiance Design Use PHP

Computers don't speak or understand English, as you probably know if you've ever shouted at yours in frustration. To get them to do what you want, you have to sort of stoop to their level (or rise to it, depending on your philosophy). Web programming is primarily about speaking to the browser on your computer in terms it can understand, i.e., a programming language. We're got ASP, Perl, Ruby, JSP and a few others, but my personal favorite is PHP.

PHP for Dynamically Created Pages

PHP is most commonly used as a server-side scripting language for creating dynamically generated websites. That means the content can be created on the fly and may vary according to the situation. For example, if a web visitor has added items to an online shopping cart, a page can be created just for him, on demand, showing him the specific contents of his cart along with the total price. A simpler example of this type of programming is the set of little images at the top left of each page of this website. The time of day picture changes according to the time of day. The flower of the month changes according to the month. And the phase of the moon changes accordingly, as well. This all happens automatically without me having to step in there every few hours and change the pictures.

PHP is like Glue

Even when a website doesn't need to do anything fancy, it is still most efficient to divide it up into separate parts, each contained in its own file. For example, the banner might go in one file, the menu in another, a sidebar in another, etc. PHP is then used to glue all the separate parts together. When something needs to be changed, say in the menu, only one file needs to be worked on instead of every page of the site. It's a type of templating.

PHP Runs on the Server

PHP runs on a web host's server rather than on your computer, unlike JavaScript, which actually is an extension of your browser and runs on your local machine. One of the main advantages of server-based scripting is that the web developer doesn't have to be concerned about differences between users' operating systems and browsers. The developer only has the behavior of a single machine to worry about: the server. Another important advantage is that server-side scripting allows secure access to databases located within the web host's environment. The icing on the cake is that while people sometimes disable JavaScript in their browser, they can't touch the code on the server. That means it will always work.

PHP Is a Scripting Language

A scripting language is a type of programming language that is usually interpreted line by line at runtime rather than compiled ahead of time. Interpreting and compilation are both operations that convert human-readable code into machine-readable code. Scripting languages are also languages which are usually used in association with other applications rather than running as stand-alone programs. PHP usually interfaces with the Apache web server software on Linux machines, although Windows versions are also available.

Before the advent of PHP, the most common server-side language was Perl. Perl was sort of, in its own way, fun. The syntax was, uh, let's say, creative. Innovative. Unusual. Well, OK, odd with a touch of spookiness. I liked it, anyway. But Perl was not originally created to be a web language. Rather, it was twisted and smooshed and tormented into taking the form of a web language. PHP, however, was written expressly for the web. It is a clean, brilliantly clear, versatile, C-like language. There are a multitude of uses for PHP, including:

  • Interacting with databases
  • Templating
  • Reading and writing files
  • Calculating
  • Dynamically created graphics
  • Shell scripting
  • Form processing
  • Creating and maintaining sessions
  • Sending email
  • Setting cookies