By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,827 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

$x[$this->some_var] in heredoc

P: n/a

I'm getting this error: Parse error: syntax error, unexpected '-',
expecting ']'

when I try to do this:

$my_here_doc = <<<my_heredoc

$x[$this->some_property]

my_heredoc;

Why is that and how to get around it without a cludge?

Jeff
Sep 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jeff wrote:
>
I'm getting this error: Parse error: syntax error, unexpected '-',
expecting ']'

when I try to do this:

$my_here_doc = <<<my_heredoc

$x[$this->some_property]
You need to wrap the variable in {} braces when dealing with
arrays/hashes:

{$x[$this->some_property]}
>
my_heredoc;

Why is that and how to get around it without a cludge?
--
Curtis
Sep 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.