Need help? Chat now!

Hostwinds Blog

Search results for:

About PHP Featured Image

About PHP

by: Hostwinds Team  /  September 14, 2019

It's officially football season here in America. During this glorious 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 competition 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 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 is much easier to learn and understand than 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 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 wait, folks. You just wait.

What is PHP?

PHP is an open-source scripting language. It is a preprocessor, meaning it interprets data from one program and translates it into the correct format for another program. PHP scripts are processed and carried out before the browser displays information to a site's user. While we're on the topic of scripts, the following 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. To properly define a scripting language, it is crucial to understand the term 'script.'

A script is a group of commands made using code. A scripting engine interprets those commands 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. After that, the interpreted data is 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 frequently 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 compatible with various content management systems and 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 love 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 task 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 (visitors can edit that) with PHP. That is one of several examples in which you can employ PHP to allow your users 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 allows PHP to make website forms where visitors input data. Not only does PHP give you the capacity to store the data users enter on your site effectively, 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 excellent 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 who they claim to be. Similarly, PHP can authorize users 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:

PHP 1 \<?PHP

A chunk of PHP code must end with:

PHP 1 ?>

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:

PHP 123

If You Type, For Instance:

PHP 123

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


For 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:

Hostwinds HTML Hype

Hostwinds HTML Hype Part 2: Tag Talk

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

PHP 123456789101112131415 function example(string $text) { echo $text; } example('Hello'); ?>

The "echo" syntax 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 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 to "test your server's PHP processing capabilities."

How to Create a PHP Info Page

One more important question before we conclude: Did you know that elephants evolved 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?

PHP has become a pivotal component of millions of applications and websites worldwide in such a short amount of time. There is no question that this language plays a significant role in what we see online 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 are geniuses.

Written by Hostwinds Team  /  September 14, 2019