The what is a variable conundrum. Thankfully the variable concept is an easy one:
Dictionary term
Variable in dictionary terms is a changeable factor or an inconstant, i.e something that isn’t always being or meaning the same.
The weather is a variable, always changing and never just “Cloudy 20 degrees with slight winds” in which has different meanings anyway. People and Pet names are the same, they are assigned but never consistent. Anthony does not refer to every person rather just “Anthony”.
Programming meaning
Variables in programming are a way to store information to be used later on. Somewhat consistent to the dictionary term… A programmer could call their API key string reference variable $api_key
whilst another may call it $key
it does not actually matter what it is called. Only when called upon does it need to be accurate to the variable name.
That example is another way to show that variables don’t always mean the same, $key
could be referencing a code or hash rather than an API key. There is no set rules on what you should call a variable.
Variables must be assigned first before use, ironic because as mentioned above the variable could mean/equal anything so it needs assigning.
$my_var = 55; //OR if (condition a is true){ $my_var = 10; } else { $my_var = 80; }
Once assigned the variable can be used over and over again.
$answer = ($my_var + 30);
The variable will keep its assigned value unless it gets reassigned.
$my_var = (400 / $my_var);