I saw this code
if (is_null($$textVarName)) {
$$textVarName = $_defaultTexts[$type];
}
what is code "$$" ?
PHP $ and $$ Variables. The $var (single dollar) is a normal variable with the name var that stores any value like string, integer, float, etc. The $$var (double dollar) is a reference variable that stores the value of the $variable inside it. To understand the difference better, let's see some examples.
PHP $_GET is a PHP super global variable which is used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL.
passing argument through reference (&$) and by $ is that when you pass argument through reference you work on original variable, means if you change it inside your function it's going to be changed outside of it as well, if you pass argument as a copy, function creates copy instance of this variable, and work on this ...
== Operator: This operator is used to check the given values are equal or not. If yes, it returns true, otherwise it returns false. Syntax: operand1 == operand2. === Operator: This operator is used to check the given values and its data type are equal or not. If yes, then it returns true, otherwise it returns false.
It's evil is what it is.
That will take the value that's in $textVarName
and use that as a variable name. For example:
$foo = 'hello';
$hello = 'The Output';
echo $$foo; // displays "The Output"
foreach($_POST as $key=>$value)$$key=$value;
now, automagically, if the previous form had a field named 'username' you now have a variable called $username that holds the value submitted in the form. not the greatest or secure method, but when you have a pocket full of nails, this is a heck of a hammer
this is pretty bad practice and is never encouraged but all PHP coders I know secretly sorta like it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With