$ vs $$ in php:
$ can be used for variables.
$$ can be used to assign the values to the existing variables values.
Sample PHP Program:
[php gutter=”false”]
<?php
$val = ‘value1’;
// Assigning values to value1 variable directly using $$.
$$val = 10;
echo "Printing val variable ::: ".$val;
echo "\n";
echo "Printing val variables value(here value1) :::".$$val;
echo "\n";
echo "Priting value1 variable value (value assigned using $$) :::".
$value1;
?>
[/php]
Output:
[plain gutter=”false”]
Printing val variable ::: value1
Printing val variables value(here value1) :::10
Priting value1 variable value (value assigned using $$) :::10
[/plain]
PHP Recommended Books: