Question:
what do variables do in php?
sdv fwef
2011-07-26 05:24:56 UTC
I know to make one you do
$variable_name = value
but I don't know when you would need to use one.
I'm trying to learn php.
Three answers:
Razibul Hassan
2011-07-26 05:56:01 UTC
Variables are temporary place holders in memory to store data (i.e. number, character or string).

When you declare, $my_var=100; A memory space is reserved for that with a name "my_var" assigned with it , and this memory block contains the value 10.



You'll use variable to store data and for calculation. Let's say, you have created 2 text fields that receive 2 numbers and on the third text-box, you'll show the summation of these 2 numbers provided by the user. How would you store the input provided by the user? Yes, you'll need variables to store it. Furthermore, to calculate the summation of these 2 numbers you need a third variable that will hold the summation of the first 2 variables.



N.B: You need very strong understanding of variables in order to learn the programming language. Please read more for details from these following URLs.



http://www.w3schools.com/php/php_variables.asp

http://php.net/manual/en/language.variables.php
Chelsi
2011-07-26 12:27:11 UTC
Variables are created to store information for later use.



For instance, if you want the user to input the number you could either get and use it directly from the textbox, or you could set a variable to the value in the textbox.
harryperales
2011-07-26 12:27:37 UTC
you need variable's when you want to store a value for later use


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...