In any language a variable is something you use to store data, normally you give a variable its name and use it by that name.
$my_var = 5;
echo $my_var;
There is this concept called dynamic variables in PHP where you can dynamically name variables for example if you needed 100 variables named var 1 to 100 you would have to write all those variables one after another and use them throughout your code.
With dynamic variables you can create the variable names dynamically in code for example in a for loop or from user input. Here is an example how you'd create 100 dynamic variables:
for($i = 0; $i < 100;$i++)
{
${"var" . ($i+1)} = $i;
}
echo $var1;
echo $var 40;
You'll have to wrap the $var with {} and concatenate with . to create dynamic variables.
$my_var = 5;
echo $my_var;
There is this concept called dynamic variables in PHP where you can dynamically name variables for example if you needed 100 variables named var 1 to 100 you would have to write all those variables one after another and use them throughout your code.
With dynamic variables you can create the variable names dynamically in code for example in a for loop or from user input. Here is an example how you'd create 100 dynamic variables:
for($i = 0; $i < 100;$i++)
{
${"var" . ($i+1)} = $i;
}
echo $var1;
echo $var 40;
You'll have to wrap the $var with {} and concatenate with . to create dynamic variables.