teravice teravice - 1 month ago 5x
PHP Question

Difference between $_session[''] & $_session[""] in php

I searched but didn't find a question about this. Is there a difference between

in PHP?

I know the difference of single and double quotes at the echo command but can't figure out the above. At my testing server it works fine both ways, but is there something deeper?


Difference is as follows:-

Eg: $key = 'demo';
In single quote, 
$_SESSION['$key'] = $key; wont work.
But in double quotes,
$_SESSION["$key"] = $key; works.

Means you can pass php variable directly in double quotes but not in single quote.