PHP Programming Tutorial for Beginners 1 PHP Tutorials
PHP Programming Tutorial for Beginners 1

May 1st, 2009:

PHP Scripting Tutorial 1

What is PHP and How to Use it?

PHP stands for Hyper Text Preprocessor. PHP is a server side scripting language and not a programming language, as erroneously mentioned in the headline of this page. Programming languages are for example C, Pearl, or Java, which can be utilized to create standalone applications. With PHP, you must have PHP installed and enabled on your server in order to use PHP.

PHP allows webmasters and developers to create dynamic content, which can be generated by using one or multiple databases. In other words: If you have a larger website with hundreds, or even thousands of pages you do not need to create every single page by hand, PHP will create these pages for you "dynamically" using the content of a database.

How To Download and Install PHP on My Home Computer?

In order to learn about PHP and to test it's functions it is recommended to installe PHP on your home computer. PHP is free open source cross platform. PHP runs on Windows XP as well as on most Linux systems, and can be built as an Apache module, which makes PHP run extremely fast and reliable.

While you're at it, I suggest you download and install Apache Server and MySQL as well.

For easier testing and to save bandwidth it is recommended to develop locally. In this case, you will want to install a web server, such as Apache, PHP and a database as well, such as MySQL.

What is PHP Used For and How Can I Use PHP With My Website?

PHP is a HTML embedded scripting language. In other words: You can add PHP commands to your HTML pages. When people visit these pages, your server processes the PHP commands and sends the result to their web browser. Besides handling the content of your web pages, you can use PHP to send HTTP headers, set cookies, redirect visitors, control cache, and manage user authentication. PHP lets you generate PDF files, connect multiple databases (Open DataBase Connectivity) or external libraries, all the way to parsing XML.

How To Add PHP To My Website?

When you add PHP to your HTML pages you will need to tell your server when the PHP code starts and when it ends.

This indicates the beginning of a PHP block:
This indicates the end of a PHP block:

The PHP engine processes everything contained inbetween those tags.

You may use the following tags as well to indicated the beginning and end of PHP code, but it is more common and useful to use the shorter version above:

<SCRIPT LANGUAGE="php"> This indicates the beginning of PHP
</SCRIPT> This indicates the end of PHP

How To Create a PHP Enabled Page?

Use your text editor (for example Notepad on Windows) to create a new file with the following content:
   <title>Test PHP</title>
 <?php echo '<p>This is my first PHP Test</p>'; 
name this file test.php and put it in your web server's root directory. Now use your web browser to go to, or if you have PHP installed on your local computer your URL should look something like this: http://localhost/test.php or depending on the configuration of your web server.

PHP processes the file and sends the output to your web browser.

If you are able to read "This is my first PHP Test" in your browser window you have configured PHP correctly.

You have just created your first PHP enabled page using the "echo" function. There are a number of available predefined variables with PHP that are very useful. To look up these predefined variables in PHP replace the code in your test.php file with the following:

   <title>Test PHP</title>
 <?php phpinfo();
The phpinfo() function lets you see a lot of useful information about your system such as configuration settings, modules, and as mentioned above, available predefined variables.

What Are PHP Predefined Variables?

Predefined Variables are predefined functions that come with PHP. As the "echo" function described above, PHP offers a lot of very useful functions which can be utilized to create interactivity and other functions used to handle tasks, such as creating dynamic web pages. The phpinfo() function lets you see all these predefined variables.

Because every system is setup differently, phpinfo() is commonly used to check configuration settings and available predefined variables on a given system.

phpinfo() Example:

// Show all information, defaults to INFO_ALL

// Show just the module information.
// phpinfo(8) yields identical results.


If you don't already have a copy of PHP, you can download it at the official PHP Web site. You'll also find a manual that documents all of PHP's functions and features.

© This Article is Copyrighted by

Please do not copy or reproduce this article in whole or part, in any form, without mentioning the source and including a live link back to - Thank You!


Copy the code below and paste into your web page
<a href="">
Webmaster Seminar</a><br />
PHP Tutorial for Beginners I

PHP Related Links