$ vs $$ in php examples

$ vs $$ in php:
$ can be used for variables.
$$ can be used to assign the values to the existing variables values.

Sample PHP Program:

$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 $$) :::".


Printing val variable ::: value1
Printing val variables value(here value1) :::10
Priting value1 variable value (value assigned using $$) :::10

PHP Recommended Books:

326 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *