Quoted from: Learning PHP, MySQL & Javascript *Basically I typed this from that book. It really helped me grasp variables.
Understanding Variables
There's a simple metaphor that will help you understand what PHP variables are all about. Just think of them as little (or big) matchboxes! That's right, matchboxes that you've painted white and written names on.
String variables
Imagine you have a matchbox which you have written the word username. You then write Fred Smith on a piece of paper and place it into the box. Well, that's the same process as assgining a string value to a variable, like this.
$username = "Fred Smith";
The quotation marks indicate that "Fred Smith" is a string of characters You must enclose each string in either quotation marks or apostrophes (single quotes), although there is a subtle difference between the two types of quote, which is explained later. When you want to see what;s in the matchbox, you open it, take the piece of paper out and read it, in PHP doing so is like this.
$current_user =$username;
Or you can even assign it to another variable! (photocopy the paper and place the copy in another matchbox.)
$current_user = $username;
I hope this can held you grasp the basic meaning of variables as it did I. Good luck guys..
Results 1 to 1 of 1
- 17 Nov. 2009 03:47pm #1
Understanding Variables (From a book)
Last edited by HTML; 17 Nov. 2009 at 03:52pm.