Well lets first start with the question what is php? Well I can't explain that pretty good so here's a explanation from Wikipedia.
Now lets start with the actual tutorial. First we'll have it about the basic syntax for variables and other things.
In PHp you can have different types of variables: array's, strings, integers, etc...
Here's an example for an array, string and integer:
| <php $string="string"; //string type 1 $string='string'; //string type 2 $integer=5; // integer $array_arr=array(); //array ?> |
You see that I use two types of enclosing for strings. I prefer the '' because then you can easily enclose html tags in the variable if you have to.
Now let's go on to our first mini-script. A basic "hello world" script. We'll present hello world in 7 different sizes on the screen. It'll be like this:
Hello world!Hello world!Hello world!Hello world!Hello world!Hello world! |
I'll first give the code and then I'll explain it bit by bit.
| <php for($i=6; $i>0; $i--){ echo "<h" . $i . ">Hello world!</h" . $i . "><br />"; } ?> |
Now let me explain the code.
First the for-loop:
| for($i=6; $i>0; $i--){ |
and we say in the loop it has to stay above 0.
Then we put
| $i-- |
what means that for every loop the for-loop does the variable $i goes down by one.
Now part two of our code:
| echo "<h" . $i . ">Hello world!</h" . $i . "><br />"; |
In this part we are echoing the different headerstyles with the text "Hello world!".
It'll have 6 different sizes.
The end of all code is done with a single bracket and the php closing tag:
| }?> |
In my next tutorial I'll explain the basics from security, loops, $_POST and $_GET.
discuss this topic to forum
