0

I am currently working on a function that needs to return a concatenated heredoc declaration. However, since my return statement is after my end delimiter I'm getting an error. For what it's worth, I have to concatenate the heredoc declaration to itself because I have loops and other logic in my function.

What is the proper way to do this? Sample code:

function trelloOutput($trello) {
  $output =  <<< OUTPUT
    <div>some stuff here</div>
 OUTPUT;

 foreach($myloop as $loops) {
   $j++;
   $output .= <<< OUTPUT
    <div> Looping stuff here $loops</div>
   OUTPUT;
 }

 $output .= <<< OUTPUT
  <div>more stuff</div>
 OUTPUT;

 return $output;
}
elke_wtf
  • 887
  • 1
  • 14
  • 30
  • Please post your code inline in the question, that is a requirement. Links to arbitrary sites are _not_ a replacement for that. A question should have a minimal code demonstrating the issue at hand. – arkascha Feb 07 '17 at 19:32
  • Apart from that: please also add the exact error message you get to your question. Thanks. – arkascha Feb 07 '17 at 19:34
  • You should be getting parse errors http://php.net/manual/en/function.error-reporting.php - RTM http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc and follow it "to a T". Your present heredoc contains trailing spaces. – Funk Forty Niner Feb 07 '17 at 19:39
  • Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Funk Forty Niner Feb 07 '17 at 19:41
  • you have spaces before all your closing identifiers, as posted. Did you use error reporting? Edit: I was responding to a comment you now deleted. – Funk Forty Niner Feb 07 '17 at 20:16
  • @Fred-ii- The closing identifiers in my live code do not have any spaces. They all start at the very beginning of the line as they are supposed to. This issue appears to be that my return statement is after the last closing identifier, and I'm not sure if what I want to do is even possible. – elke_wtf Feb 07 '17 at 20:57

0 Answers0