PHP Tutorial – Part I

Why PHP?
Why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. Learning a scripting language, or even understanding one, can open up huge new possibilities for the website. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.
Using scripts on your website allows you to add many new ‘interactive’ features like feedback forms, guestbooks, message boards, counters and even more advanced features like portal systems, content management, advertising managers etc. With these sort of things on your website you will find that it gives a more professional image.

What Do I Need?
PHP is a server-side scripting language. This means that, although your users will not need to install new software, you web host will need to have PHP set up on their server. It should be listed as part of your package but if you don’t know if it is installed. If your server does not support PHP you can ask your web host to install it for you as it is free to download and install.

Writing PHP
Writing PHP on your computer is actually very simple. You don’t need any special software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script.

Declaring PHP
PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows:

PHP Code In Here

PHP Code In Here

<script language=”php”>
PHP Code In Here
All of these work in exactly the same way.

Your First Script
The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor:

As you can see this actually just one line of code. It is a standard PHP function called phpinfo which will tell the server to print out a standard table of information giving you information on the setup of the server.
One other thing you should notice in this example is that the line ends in a semicolon. This is very important. As with many other scripting and programming languages nearly all lines are ended with a semicolon and if you miss it out you will get an error.

Like to share it
Tags: php,

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *