Home » Web Design » Web Design – PHP Intro

Web Design – PHP Intro

PHP 

php

History of PHP

The first version of what came to be known as PHP was created in 1995 by a man named Rasmus Lerdof. At this time, HTML (Hyper Text Markup Language) was the only means to create a webpage. Rasmus was looking for something to work along with HTML, yet provide him more power and remain easy to create the content in his web pages. Adopting the Perl language, he created scripts to handle his web pages. He called this new technology “Personal Home Page/Forms Interpreter”. This was later shortened down to “PHP/FI”, and later came to be known simply as “PHP”.  Not until 1997, with the PHP version 3, did we see an explosion of the use of PHP.

 

How does PHP work?

Recall the html files or posts/pages in your website are only files. When a user clicks to view your webpage, the file is transmitted to the users PC’s browser. That browser then interprets the view of the webpage, based off the html, javascript, ECT. (This is why we see HTML code to define how each possible browser should interpret the page)

PHP works differently. Rather than sending a PHP file over to the web browser (it would not know how to interpret it), PHP is a preprocess module. What this means is, PHP is a scripting language within the web server. When a user requests your webpage, having PHP on the server, that request passes into the PHP pre-process module. The script creates then content (file) to be sent to the user.

So, rather than a simple file being passed to the web browser, PHP creates the file prior of sending to the web browser.

 

How does PHP look?

 

Below is a simple HTML code, with PHP embedded in the body. “<?php”  tells the webserver, this is PHP.

<html>
<head>
<title>A PHP Example</title>
</head>
<body>

<?php
echo ‘<p>This line of HTML was generated by a PHP script embedded into an HTML document</p>’;
?>

</body>
</html>

 

The PHP module would interpret the php code, prior to sending out to the web browser. The web browser will never see “<?php”.

 

<html>
<head>
<title>A PHP Example</title>
</head>
<body>

<p>This line of HTML was generated by a PHP script embedded into an HTML document</p>

</body>
</html>

The web browser will only receive the above information.

Usability of PHP?

PHP scripting is executed in the web server before providing the content to the end user. Note Javascript scripting is executed in the end users web browser. PHP is more efficient when providing information to the end user.

Let’s give a scenario to better understand this.

A large database resides on the web server, containing inventory. The end user is requesting a search for specific information on that database.

Use of Javascript:

  • End user sends the information
  • Javascript sends end user it’s code
  • End user web browser translates the code
  • The request is resent to pull the database information
  • The requested information is sent to the end user

Use of PHP:

  • End user sends the information
  • PHP translates the code on the web server, with database
  • The requested information  is sent to the end user

In this crude example, we see PHP falls between at static HTML page, and JavaScript. But more importantly PHP’s design is different than Javascript, by processing on the web server, prior to sending the content.


Leave a comment

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