They are containers enabling to store information that is reusable in multiple positions in code
Statement: To select the name of a variable you must :
Check that this name is available (key word or variable of language) ;
That the name in embedded with letter, figures or _ (underscore) ;
That the first character is NOT capital letter ;
With PHP enter the symbol $ in front of the first letter.
Allocation : We use the symbol = to fill in a container with data:
myvar_1 = "hello"
$myvar_1 = "hello";
put the string "hello" in the variable
myvar_2 = 250
$myvar_2 = 250;
put the number 250 in the variable
myvar_3 = true
$myvar_3 = true;
put the value true in the variable
myvar_4 = myvar_2
$myvar_4 = $myvar_2;
put in the myvar_4 variable the value included in the variable myvar_2
Categories : So, you understand that you cannot reserve the the same memory space to put in storage a number and a long chain of characters... Also, the language needs to know the kind of information that a variable contains.... Each variable is classified when first built-in; it means the kind of information stored in the variable is primarily determined... Be aware of any mistake you can enhance if you do not respect this rule!
Read : A data in a container is readable just by mentioning its name
For example, if you want to post: <% = myvar_1 %> or <? echo $myvar_1; ?>
Operations : We can, obviously, build the content of a variable in a different and smarter way... Some examples:
Dynamic variables: Sometimes, it could be better to store (or build) a variable within another variable ... And, we will develop as follow to read its content:
<% truc_fr = "Bienvenue" truc_en = "Welcome" lang = "fr" execute "response.write truc_" & lang %>