Recent Notice
You need to log in to create posts and topics. Login · Register

PHP for beginners (part-01)

PHP Tutorial - Learn PHP

If you want to learn the basics of PHP, then you've come to the right place. The goal of this tutorial is to teach you the basics of PHP so that you can:

• Customize PHP scripts that you download, so that they better fit your needs.

• Begin to understand the working model of PHP, so you may begin to design your own PHP projects.

• Give you a solid base in PHP, so as to make you more valuable in the eyes of future employers.

PHP stands for PHP Hypertext Preprocessor.

PHP - What is it?

Taken directly from PHP's home,, "PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly."

This is generally a good definition of PHP. However, it does contain a lot of terms you may not be used to. Another way to think of PHP is a powerful, behind the scenes scripting language that your visitors won't see!

When someone visits your PHP webpage, your web server processes the PHP code. It then sees which parts it needs to show to visitors(content and pictures) and hides the other stuff(file operations, math calculations, etc.) then translates your PHP into HTML. After the translation into HTML, it sends the webpage to your visitor's web browser.

PHP - What's it do?

It is also helpful to think of PHP in terms of what it can do for you. PHP will allow you to:

• Reduce the time to create large websites.

• Create a customized user experience for visitors based on information that you have gathered from them.

• Open up thousands of possibilities for online tools. Check out PHP - HotScripts for examples of the great things that are possible with PHP.

• Allow creation of shopping carts for e-commerce websites.

What You Should Know

Before starting this tutorial it is important that you have a basic understanding and experience in the following:

• HTML - Know the syntax and especially HTML Forms.

• Basic programming knowledge - This isn't required, but if you have any traditional programming experience it will make learning PHP a great deal easier.

Tutorial Overview

This tutorial is aimed at the PHP novice and will teach you PHP from the ground up. If you want a drive-through PHP tutorial this probably is not the right tutorial for you.

Remember, you should not try to plow through this tutorial in one sitting. Read a couple lessons, take a break, then do some more after the information has had some time to sink in.

PHP - Syntax

Before we talk about PHP's syntax, let us first define what syntax is referring to.

• Syntax - The rules that must be followed to write properly structured code.

PHP's syntax and semantics are similar to most other programming languages (C, Java, Perl) with the addition that all PHP code is contained with a tag, of sorts. All PHP code must be contained within the following...

PHP Code:



or the shorthand PHP tag that requires shorthand support to be enabled

on your server...



If you are writing PHP scripts and plan on distributing them, we suggest that you use the standard form (which includes the ?php) rather than the shorthand form. This will ensure that your scripts will work, even when running on other servers with different settings.

How to Save Your PHP Pages

If you have PHP inserted into your HTML and want the web browser to interpret it correctly, then you must save the file with a .php extension, instead of the standard .html extension. So be sure to check that you are saving your files correctly. Instead of index.html, it should be index.php if there is PHP code in the file.

Example Simple HTML & PHP Page

Below is an example of one of the easiest PHP and HTML page that you can create and still follow web standards.

PHP and HTML Code:



<title>My First PHP Page</title>




echo "Hello World!";





Hello World!

If you save this file and place it on PHP enabled server and load it up in your web browser, then you should see "Hello World!" displayed. If not, please check that you followed our example correctly.

We used the PHP function echo to write "Hello World!" and we will be talking in greater depth about this PHP function and many others later on in this tutorial.

-------------------------------------------------------- please waiting for part 02------------------------------------------------------------ • Free Website Templates - Downlaod Full Themes