On Sat, Jul 11, 2009 at 11:03 AM, Daniel Brown<danbrown@xxxxxxx> wrote: > On Sat, Jul 11, 2009 at 10:42, Ashley Sheridan<ash@xxxxxxxxxxxxxxxxxxxx> wrote: >> >> The braces ensure that PHP doesn't stop parsing the variable name once it >> reaches the [. By default, it will only match a variable name up to the [ >> sign, so you couldn't access arrays without the braces. > > Couldn't have said it better myself. > > As for the braces in the HEREDOC around {$somevar}, while it works > absolutely fine, it was a typo on my part: I intended to show all > manner of usage and processing of variables within the HEREDOC syntax. > However, in my own code, I generally include all variables between > {braces} when inside a HEREDOC block. Sheer preference for > readability in a large HEREDOC: because I don't normally use curly > braces around variables, when I see that on the page, I instantly > recognize that I'm still in the block (if all other clues miraculously > fail --- and we all know that they sometimes do). > > -- > </Daniel P. Brown> > daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx > http://www.parasane.net/ || http://www.pilotpig.net/ > Check out our great hosting and dedicated server deals at > http://twitter.com/pilotpig > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Uhm.... you don't need braces around arrays unless you're using more than one dimension in the array. This works perfectly fine for me: <?php $bar = array('hello' => "goodbye"); $foo = <<<EOT $bar[hello] EOT; echo $foo; //echos out goodbye ?> Something this simple should be common knowledge :X but I still agree with Daniel that you ought to use {} around variables in HEREDOC (or double-quotes) as it makes your code much more readable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php