Do I use single or double quotes for predefined variables like $_GET and $_COOKIE?

Is it best to use single quotes or double quotes for predefined variables like $_GET, $_POST, $_COOKIE and others?

The examples in the PHP Manual, for the section on predefined variables, use single quotes in some places and double quotes in other places.

PHP Manual Predefined Variables

Is there somewhere in the PHP Manual that tells where it is appropriate to use single quotes and where it is appropriate to use double quotes with the predefined variables?

Thanks.

doesn’t matter - personal preference

Just bear in mind;


$var = 'hello';

echo "Say $var";  //works - PHP expands the variable inside double quotes
echo "Say " . $var; // works
echo 'Say $var';  // does not work
echo 'Say ' . $var ; // works

$_POST['msg'] = "hello"; // $_POST is an array

echo "Say $_POST['msg']";  // does not work - does NOT expand the var in an array
echo "Say " . $_POST['msg'];  // works
echo 'Say $_POST['msg']';  // does not work
echo 'Say ' . $_POST['msg'] ; // works

One that Cups missed from his post is:

echo "Say {$_POST['msg']}";