1 Variables in PHP Wed Dec 29, 2010 12:42 am
Unknown Data
Registered Member
Variables in PHP Learn PHP - part 3 |
To define a variable In PHP are we indicating our variables with a dollar sign followed by a name, but remember also that PHP is case-sensitive, ie. there is a differences between big and small letters. All variables starts with big letters or a underscore (no numbers are allowed) followed by the name written with letters or numbers. Here is some examples of the variables:
In a document will it look like this: Now am I writing something by using the PHP variables. Variables as reference If we want to make a reference with another variable, are we only going to add this sign "&", before the variable. I've added a example again:
It will then look liek this: Hello World! Hello World! Variables in a form Try pasting this inside your document and you'll see that it'll show up a funny little thing. I'll start explaining it after you've viewed the whole source
All right. There isn't the big to explain about the HTML form. The only special stuff that we want to know more about is the PHP_SELF. This part of the code will return the file, plus the content inside the variables name. The echo $_REQUEST part will return the content inside the form field "name". In stead of using the $_REQUEST, could I've also used $_POST, because that's the method for sending data in my case. If I want to receive something, can I use $_GET. A little bit about array Before we switch to the next tutorials are we taking a short look at arrays. In the example have I defined an array as $fruits, that contain five fruits. Each of these names can I flow the command echo $fruits[]. Remember that the first name should have [0]! '
To find the fruit banana am I writing echo followed by $fruits[2];, if I then want to find grape am I writing $fruits[4]; instead of $fruits[2]; etc. In the next lesson will we take a look at loops. |
Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators. |