DEV Community

hartsean
hartsean

Posted on

A brief history of PHP

PHP was my first introduction to any Programming language. In retrospect, it was a good introduction, and many of the concepts I picked up in my 'Advanced Music Tech' class that for some reason focused on PHP primarily and had us making dynamic webpages for musicians and a soundcloud-esque music player, have been extremely helpful in learning new languages and coding other types of programs. Today I want to talk about the history behind PHP, as well as some general use cases and code examples.

PHP is a scripting language that was created in 1994 by Rasmus Lerdorf. Originally, he has written some programs in C to perform some actions on his static website he had created for himself on the newly burgeoning internet. In doing so, he had unintentionally laid the foundation for new programming language, one that's purpose was primarily to interact with the servers and databases used to house his static files, and bring more life to the static sites that were the status quo of the internet at the time.

PHP stands for 'HyperText Pre-Processor' which is a recursive algorithm. Not only was this term coined by one of my favorite authors Douglas Hofstadter, but the recursive algorithm naming convention was a programming inside joke at the time PHP was created, and more of these 'jokes' a.k.a not to helpful when learning the definitions of things are found in the PHP code base and name.

PHP is scripting language, and it serves a wide range or purposes. Originally intended to handle form data on static websites, it has been developed to become its own programming language used to interact with databases and servers.

It can be embedded in HTML. Inside a normal HTML document, you can execute php code by adding the tags:

..some php
?>

..some html

<?php
...some more php
?>

It is a loosely typed language. Meaning that you don't have to specify the datatype when you are declaring or executing variables in the code. This makes it actually a little easier for beginners to pick up, as you don't have to be exactly specific about using common datatypes and it cleans up the syntax a great bit. However, you can opt in to this feature which is required in other programming languages such as C.

Here's some examples to get an idea of the syntax:

<?php
function printRole($a, $b) {
$role = "Student";
echo "{$a} + {$b}, is currently a {$role}";
}
?>
...SOME HTML
<?php 
printRole(‘John’, ‘Smith’);
?>

Another useful feature is that arbitrary code can be executed via the Command Line Interface. Also, PHP Can be used on any operating system or database, because it's been around forever and has become the standard. Most servers these days have a PHP interpreter module.

Hoping this article can serve as jumping off point in deciding what and why you would want to use this now classic programming language.

Top comments (0)