Jump to content
MakeWebGames

Recommended Posts

Posted

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.

Posted
$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)

Posted

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??

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...