What is PHP?

 

Introduction.  PHP Originally, PHP was an acronym for Personal Home Page.   It was created in 1994 by Rasmus Lerdorf to track the visitors to his online resume.  After other developments it has now largely become PHP: Hypertext Preprocessor

PHP is

  • a scripting language that can be embedded into HTML
    • it is not precompiled like a programming language would usually be
  • processed at the occurrence of some event
    • when the page is requested
    • when the user submits a form
    • other events
  • processed on the server so it is called server side scripting
  • an approach that increases the capability for users to interact with a website and/or databases

The following diagram gives a representation of the interactions between the client and the web server.

 

 

Thus
  • a client sends a request for a particular page on a web server
    • if this page has PHP that needs to be processed based on user interactions it is sent to the PHP processor on the web server and processed
    • this processing returns HTML to the web server
  • the results of the user request is returned as HTML developed from the original HTML on the page and the HTML developed from any PHP requests

Interacting with a database, such as MySQL isn't much different.  A three tiered configuration is represented by the following diagram.

 

 

Notice all of the database interactions are done through some sort of query written into the PHP code and submitted during the PHP processing.

Some Syntax.  With these things in mind it is important to develop the overall syntax that is usually used to let the server distinguish between HTML and PHP script.  One of the main things done to signal the web server that a file contains PHP code is to give it a .php extension.

 Since HTML files are tag delimited "nodes", PHP interfaces with this approach by using

<?PHP

PHP script

?>

and/or

<?

PHP script

?>

to delimit the PHP scripting.  There are often several such blocks of code within a file.  It can also be interesting to see the rather strange places this embedding can occur!  But more about this throughout the course.