I was wondering how, if possible, I would be able to run a function in a heredoc syntax, e.g.

How would I do this:

echo <<<EOT

foreach($a->$b as $c) {echo $c }

EOT;

EDIT: I know the title says "some questions", but I found most of my answers at php.net.

    You can't execute PHP functions inside a heredoc block. You can only evaluate variables.

    Maybe heredoc syntax isn't what you need here. What are you wanting to do anyway?

      I had a HTML template that I wanted to parse as a string. The template mostly used variables to set dynamic values, however, one setting used a foreach loop so I couldn't pass it.

      There is a story behind why I wanted to do that, and it was quite plausible, however I need no longer seem to need to do this, it seems, so I can let it be.

      Thanks for you input! You wiped the last question mark regarding heredoc from the electronic circuits of my brain.

        Write a Reply...