Gucci Mane Posted November 17, 2009 Posted November 17, 2009 I am studying PHP, on w3schools.com. I just started earlier, I dont get the variables thing why do I need them what do they do? When do I call them? Why do I call them? Please help Thanks Quote
Gucci Mane Posted November 17, 2009 Author Posted November 17, 2009 I do not understand why and where I need to use a variable and what it does Quote
Gucci Mane Posted November 17, 2009 Author Posted November 17, 2009 yes lol $var_name = value; I know every variable has to start with a $ and then if the name of the variable is 2 words it would be $myTime or $my_time Quote
Redex Posted November 17, 2009 Posted November 17, 2009 Good luck, with learning php mate. Hopefully in future you will be a good coder :P. Quote
a_bertrand Posted November 17, 2009 Posted November 17, 2009 I must admit I'm lost, on one side you know what a variable is, and before you say you don't know how to use them. A programming language without variables would not be a programming language as you would not be able to store information nor react to some conditions. Quote
Zero-Affect Posted November 17, 2009 Posted November 17, 2009 $other_var = "var"; $var_name = $other_var; if ( $var_name == $other_var ) { echo "$var_name is $other_var"; } OUTPUT: var is var Basically a Variable is a Statement like in MC codes variables are used for things from stating a username bolded IE: $username = "[b]" . $ir['username'] . "[/b]"; They come in handy quite alot, i never used w3schools or php.net when i first started so i actually wouldn't have any idea for the real name of some functions or options but variable is pretty straight forward. (i maybe incorrect) Quote
Gucci Mane Posted November 17, 2009 Author Posted November 17, 2009 I mean like what kinda information do they store?? Where should I use them??? $txt="HELLO, MWG Foum rocks!"; ^^ That is a variable right?? So anywhere throughout the document if I put ::: echo $txt; HELLO, MWG Forum rocks! ; Would out put where ever I put the echo $txt; Right?? Quote
a_bertrand Posted November 18, 2009 Posted November 18, 2009 yes right. Variables can store basically anything, from a single text line like you mentioned, to complex structure like nested tables and more. Where to use them? Well anywhere you need them, I mean, as soon as you need to store something you can use them. However remember that variables will not survive between two page loads (until you use the special array $_SESSION. Quote
Gucci Mane Posted November 18, 2009 Author Posted November 18, 2009 Yea, Im gonna start learning about them after school. So if I have any more problems. Ill open a new topic! :) Thanks guys Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.