Gen. partnerAlgotech

Variables Variables

Consider the following example:

|
August 22, 2019

Warning: This article was written many years ago and some information may be outdated or incorrect. Please bear this in mind when reading.

Variables are not intended for common deployment (they solve problems that can be solved in other ways), they are mainly used to make writes more concise and memory accesses more complex.

Consider the following example:

$x = 25; // contains 25
$nacitana_promenna = 'x'; // contains "x"
$y = $nacitana_promenna; // contains 25
echo $y; // prints 25

Note the two dollars following each other. In this case, the value of the variable $y will be loaded into the variable that has the name contained in the $nacitana_variable.

A little confusing, huh? That's why you'd better not use variables.

Note: Variable variables are a specialty of PHP because of the dollar sign. In other languages, the beginning of a variable name is not marked with any character, so you cannot use variable variables because it would be ambiguous when it is a classical variable and when it is not.

Loading comments...

Stay in the loop

Subscribe to our newsletter and get the latest cybersecurity news delivered straight to your inbox.

Your data is safe. You can unsubscribe from the newsletter at any time.