About PHP

It’s officially football season here in America, and during this resplendent time of year, it is a good idea to find a hobby to engage in between games. Incidentally, we’ve been gearing ourselves up for this week’s game by brushing up on our PHP skills.

PHP, or Hypertext Preprocessor, is a scripting language generally used to automate back-end tasks for websites and software applications. This language is paradoxically known to be both easy to learn and complex in terms of what you can use it to accomplish. Although corporations like WordPress and Facebook employ PHP, the scripting language happens to be much easier to learn and understand compared to other languages.

Since Rasmus Lerdorf first founded it in 1994, PHP has been used to carry out automated tasks on websites, work with complex databases, and much, much more. PHP is a great tool to utilize in order to make a website more dynamic. You could, for instance, use PHP to showcase a series of dancing elephant GIFs on your website.

Example #1
Example #2

By the way, important question: Did you know elephants purr?

Don’t worry, we’ll explain why we asked the important elephant question in a bit. In the interim, let’s get to know PHP just as we got to know elephants a little better mere moments ago. Speaking of, important question: Did you know that elephants use mud as sunscreen so they don’t get a sunburn? What’s that? You are curious to know where all this elephant talk is coming from? Oh, you just wait, folks. You just wait.

What is PHP?

PHP is an open-source scripting language. It is is a preprocessor, meaning it interprets data from one program and translates it into the right format for another program. PHP scripts are processed and carried out prior to the point where the browser displays information to a site’s user. While we’re on the topic of scripts, the subsequent definition will provide you with more context about the way PHP functions.

Definition of a Scripting Language: Generally, scripting languages are used for scheduling tasks automatically. In order to properly define a scripting language, it is important to understand the term ‘script.’

A script is a group of commands made using code. Those commands are interpreted by a scripting engine at runtime. The scripting engine on which PHP runs is called Zend Engine. Thus, commands in the form of PHP code are interpreted by Zend Engine. The interpreted data is thereafter sent to the browser to display to the website viewer in a digestible format. Other scripting languages include Ruby and JavaScript.

On another note, PHP uses tags and scripts. A line of PHP code is called a statement, and statements always end in a semicolon. Well, not always. If only one statement exists, it doesn’t require a semicolon, but only in that one case. Speaking of ‘case,’ PHP is case sensitive. Furthermore, PHP files end with the extension .php.

Interestingly enough, it is possible to integrate PHP with other languages, including HTML. PHP is oftentimes embedded into an HTML document.

The term ‘diverse’ aptly describes this particular scripting language, as PHP commands can even be executed using a command line. PHP is ubiquitous in that it is not only compatible with various content management systems, but also multiple frameworks. PHP is a cross-platform language, meaning it works on an assortment of operating systems. Nearly every server used for hosting services can work in compliance with PHP. Speaking of server, did you know that PHP is a server-side scripting language?

What is a Server-Side Language?

Definition of Server-Side Language: This means that the server executes the commands dictated by code before the information is sent to a browser. The code is carried out on the server. In other words, PHP deciphers the commands stated in the script on the server. From there, that information is sent to the website’s viewer.

JavaScript, by contrast, is a client-side language.

What is the Difference Between Server-Side and Client-Side Languages?

Client-side languages like HTML and JavaScript have the browser execute their commands. The difference between server-side and client-side is a difference between the browser translating code into what is displayed on a site and a server translating code into what is displayed on a site.

P.S. There is no need for compiling when using PHP to execute commands.

Why Would One Use PHP?

Some of the many things that can be achieved using PHP are as follows:

Automated Tasks & Dynamic Content

PHP developers use the scripting language to create much more complex
website content than a series of whimsical elephant GIFs.

Oh, and to that end, we’ve got yet another important question for you: Did you know that elephants can hear sounds that go undetected by the human ear? What’s that? You are loving all this elephant information, and although you don’t understand why it keeps coming up, you want more?

You don’t need to ask us twice! Did you know that elephants sleep less than 4 hours a day on average?

Now that we’ve got that out of the way, here is another automated tasks you can take care of by coding with PHP: The resilient PHP is also used for calculating math operations. It can even improve/optimize the functionality of a site.

You can generate intricate graphics such as avatars (that can be edited by visitors) with PHP. That is one of several examples in which you can employ PHP in order to give your users the opportunity to interact with your website’s elements.

Tasks Entailing Grabbing From or Adding to a Database

PHP is often used to grab from or add to MySQL databases. This language extracts information from databases, then presents it to website users. Applications that run using a DBMS (Database Management System) usually work in conjunction with PHP.

Grabbing from and adding to a database is what allows PHP to make website forms where visitors input data. Not only does PHP give you the capacity to effectively store the data users enter in on your site, but it also enables you to edit certain stored information.

In addition, PHP helps with actions such as sending cookies and storing forum information. PHP can also be used for security purposes.

Tasks Pertaining to User Roles, User Authentication, & User Authorization

PHP is great for setting up user authentication. Password and credential data can be set up on the back-end using the language. PHP developers build user permissions that confirm people are in fact who they claim to be. Similarly, PHP can be employed in order to authorize that users are able to do what they want to do on a website.

A Little Bit of PHP Syntax

Finally we are getting to the fun part. It is time to learn some PHP syntax!

A chunk of PHP code must begin with:

A chunk of PHP code must end with:

These are instructions. The instructions say, “This is where the PHP begins, and this is where the PHP ends,” respectively.

On that note, you can type any PHP function within these PHP tags:

If You Type, For Instance:

This is the Output That Would be Displayed on a Website:

Hostwinds

For the purposes of this blog piece, we’ll embed some PHP into a basic HTML page.

P.S. If you need help getting started with HTML, click one or both of the links below:

Here is a PHP function provided by Matthew, Hostwinds’ skilled PHP developer. We have embedded the PHP function into HTML.

The “echo” syntax basically means, “Display, or echo, the following information on the website.” Do you see why people say PHP is so easy to learn? Its syntax is similar to English words!

Additionally, the “Function” portion of this PHP code commands the server to execute a task of some kind. This PHP function, in particular, takes in any text or string of characters that a user inputs into your site and displays it (or, ‘echos’ it) on the web page. The “example (‘Hello’);” portion dictates that the string of characters is ‘Hello.’ Therefore, the web page would display the word ‘Hello.’

That is clearly the tip of the iceberg when it comes to PHP, but rest assured Hostwinds will be providing you with further examples of PHP syntax in subsequent blog posts. Oops, that was a Spoiler Alert!

P.S. Click the link below to view a Hostwinds Knowledge Base guide about building a PHP info page in order to “test your server’s PHP processing capabilities.”

One more important question before we conclude: Did you know that elephants evolved over time to have long trunks as a means to swim further and deeper? Their trunks were created to act as snorkels. How unbelievably adorable!

Why the Relentless Elephant References, You Ask?

In such a short amount of time, PHP has become a pivotal component of millions of applications and websites worldwide. There is no question that this language plays a significant role in that which we see online each and every day.

Speaking of ‘significant,’ it is time for another important question: Did you know that elephants can be pregnant for almost two years? Whoa, no wonder female elephants govern their herds!

What’s that? You’d like us to finally reveal why we have been peppering elephant information into nearly every section of this blog piece?

Answer Revealed:

PHP’s mascot is an elePHPant!

Wow, PHP creators, you really are geniuses. You really are.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.