PHP Introduction
This page provides a quick overview of PHP.
What Is PHP?
PHP (PHP: Hypertext Preprocessor) is a server-side scripting language intended to help web developers build dynamic web sites quickly.
How Does PHP Work?
PHP scripts are executed on the server, before the web page is displayed to the user (this is what we mean by "server-side"). The user only sees the end result, which consists of client-side markup and scripts (i.e. HTML, JavaScript, CSS etc). Therefore, the user/browser doesn't actually see any PHP code. If the user views the source code, all they would see is HTML, JavaScript, CSS etc - they wouldn't see any PHP code.
This happens because, whenever the server processes a file with the .php extension, it knows to look for PHP code. When it encounters the PHP code, it processes it. Generally, the same .php file will also have client side code such as HTML. The server knows to process the PHP bits and output the client-side bits. You, as the programmer, determine which pieces of HTML will be displayed and when. You do this using PHP code.
What Can PHP Do?
PHP enables you to build large, complex, and dynamic websites. PHP can also increase your productivity enormously, both in development time and maintenance time.
Using PHP, you can build websites that do things such as:
- Query a database
- Allow users to upload files
- Create/read files on the server (for example, the files that your users upload)
- Have a "member's area" (i.e. via a login page)
- Have a shopping cart
- Present a customized experience (for example, based on users' browsing history)
- Much, much more
What Do I Need to Create PHP Code?
You can create PHP code using the same equipment you use when creating HTML. That is, a computer with the following software:
- Text editor. For example, Notepad (for Windows), Pico (for Linux), or Simpletext (Mac). You could use a special HTML or PHP editor if you like but it's not needed.
- Web Browser. For example, Internet Explorer or Firefox.
What Do I Need to Run PHP?
To run the PHP pages you create, you need a computer with the following software:
- A web server (such as IIS, Apache etc)
- PHP
If you don't have these installed, you have a couple of options (apart from giving up!). The next lesson will point you in the right direction.