Posts Tagged ‘PHP scripts’

What is PHP

Whenever anyone is learning PHP, the most common questions that first come up are: What is PHP? And how does it work?

It is precisely these questions we will look at in this lesson. It's a big help to understand such basics related to PHP before you start developing you own PHP pages. Such basic understanding will increase the speed of learning significantly.

So, let's get started!

What You Should Already Know

Before you continue you should have a basic understanding of the following:

  • HTML
  • JavaScript

What is PHP?

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a widely-used, open source scripting language
  • PHP scripts are executed on the server
  • PHP is free to download and use

PHP was originally an acronym for Personal Home Pages, but is now a recursive acronym for PHP: Hypertext Preprocessor.

PHP was originally developed by the Danish Greenlander Rasmus Lerdorf, and was subsequently developed as open source. PHP is not a proper web standard – but an open-source technology. PHP is neither real programming language – but PHP lets you use so-called scripting in your documents.

To describe what a PHP page is, you could say that it is a file with the extension . php that contains a combination of HTML tags and scripts that run on a web server.

What is a PHP File?

  • PHP files can contain text, HTML, JavaScript code, and PHP code
  • PHP code are executed on the server, and the result is returned to the browser as plain HTML
  • PHP files have a default file extension of ".php"

What Can PHP Do?

  • PHP can generate dynamic page content
  • PHP can create, open, read, write, and close files on the server
  • PHP can collect form data
  • PHP can send and receive cookies
  • PHP can add, delete, modify data in your database
  • PHP can restrict users to access some pages on your website
  • PHP can encrypt data

With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML.

Why PHP?

  • PHP runs on different platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • PHP has support for a wide range of databases
  • PHP is free. Download it from the official PHP resource:
  • PHP is easy to learn and runs efficiently on the server side

How does PHP work?

The best way to explain how PHP works is by comparing it with standard HTML. Imagine you type the address of an HTML document (e.g. in the address line of the browser. This way you request an HTML page. It could be illustrated like this:

php tutorial

As you can see, the server simply sends an HTML file to the client. But if you instead type – and thus request an PHP page – the server is put to work:

php tutorial 02

The server first reads the PHP file carefully to see if there are any tasks that need to be executed. Only when the server has done what it is supposed to do, the result is then sent to the client. It is important to understand that the client only sees the result of the server's work, not the actual instructions.

This means that if you click "view source" on a PHP page, you do not see the PHP codes – only basic HTML tags. Therefore, you cannot see how a PHP page is made by using "view source". You have to learn PHP in other ways, for example, by reading this tutorial.

What you learn in this tutorial is to write commands to a server!

So, the first thing you need to get ahold of is… a server! But don't worry – you don't need to buy a new computer. You just need to install some software on your computer that makes it function as a server. Another option is to have a website on a hosted server that supports PHP. Then you just need to be online while coding.

Next Chapter »

Designed for