What is PHP and why you should learn it

Luisojeda
4 min readFeb 24, 2020

--

Photo by Luca Bravo on Unsplash

What is PHP?

Expanding on the information from my last post, PHP is a scripting programming language that has been used for more than 2 decades.

Programming language and its dynamic

As a general purpose scripting language, PHP allows you to create any kind of program that you would like as complex or simply as you would prefer to. It also helps you make dynamic and very fast web pages with ease.

HTML embedded

This programming language is embedded in HTML. This means that you can add PHP code to any html page that you have previously created without affection the current functionality of that HTML and just adding more to it. This can be extremely helpful if there’s something that you want to add something new to your html without having to change the code that you already have worked on for hours.

Syntax intro

Most basic PHP program — Luis Ojeda

In this very simple program (basically a “hello world” page) we can see some interesting things about how to program with PHP. First of all, the outer structure of the program is basic HTML that every person in a CS or IT field has seen before. This part can be auto-generated by any IDE that you prefer to use. The PHP part starts in the moment you open the <?php tag and it finishes in the ?> tag.

By looking at this image with this explanation, it’s now more clear how you don’t need to change anything at all from the rest of you HTML page when you want to use PHP. You can just open the tag and close it, and inside of it insert the PHP functionality that you would like to use.

“echo” is the most basic key word you will see in PHP, being this the equivalent of “System.out.println()” in a java program. By typing the word echo followed by the text that you want to show in the screen (inside double quotes (“”)), you can print to the screen whatever you want. Finally, you need to finish the line with a semi-colon (;) just like java.

History

It’s name, PHP, originally came from “Personal Home Page”. It was based on how its creator, Rasmus Lerdorf, just wanted to expand the functionality and dynamics of his personal homepage (his resume). This happened in 1994 when Rasmus was writing CGI programs in C to maintain his page, but then he started implementing more and more functionalities, connections with databases and dynamics until what he created was transformed into PHP.

It eventually evolved into the PHP that we know nowadays. In today’s world, PHP is more known as “Hypertext Preprocessor” (a recursive acronym) due to the fact that it processes the PHP code into HTML in the page prior to the page being loaded into the user’s computer.

Inconsistencies

Originally, PHP wasn’t mean to be a programming language. It just started to grow once Lerdorf released its first version until it became a completed programming language. This lead to having some inconsistencies in the early syntax of the language and the current syntax. This applies specially to some functions and keywords that their names may differ if you look at different versions of PHP.

PHP nowadays

The most current version of PHP is version 7. Specifically, version 7.4.3 that was just released a few days ago prior to the publication of this post. However, version 7.3 and 7.2 are also constantly having new releases (7.3.15 and 7.2.28 being the most current ones). This shows that the technology is still being worked and improved every day, and allowing the users to use the version that they can fit the best to their needs.

By the end of this year, or the first quarter of next year, version 8 of PHP will be released. Even though version 7 was released less than 6 years ago, a new complete version of it is already being developed and showing how much the technology is being worked on and improved to maintain nowadays programming standards.

Why PHP?

To recap and expand on the importance and why use PHP of my previous post:

  • It’s very good for the security aspect of web pages
  • It’s excellent to work with widely used DBMS such as MySQL, Sybase, Oracle, and others (being this basically one of its original and most important functions).
  • It’s a cross-platform technology, so it doesn’t matter if you are a Linux, Windows, or MacOS person, you can easily create and run PHP web apps and web pages without any problem.
  • It’s still in the top 15 most used programming languages in the world, so there’s a high possibility that any CS/IT person will encounter it at some point of their career.
  • It’s extremely comfortable and easy to use and learn. Its syntax is really simple and it allows to create complex programs without much problem. Finally, since it’s HTML embedded, you can learn most of its functions by adding extra functionalities to any HTML page that you have previously created and you will be able to understand how it works and most of its syntax in a few days of using it.

--

--