Jump to content

[SOLVED] Heredoc causing problems?


Styles2304

Recommended Posts

I had a calendar full of echos that got rather sloppy so I upgraded to a heredoc to improve readability and upgradability. However, when i did that, the code fell apart. I've done some debugging and have narrowed it down to this chunk right here:

 

    if (($i == date("j")) && ($month == date("m")) && ($year == date("Y"))) {
      $EventEOD .=<<<EOD
        <td width="110px" height="103px" valign="top" align="center">
          <div class="date_header_today">
            <font class="days_today">$i</font>
          </div>
EOD;    
    } else {
      $EventEOD .=<<<EOD
        <td width="110px" height="103px" valign="top" align="center">
          <div class="date_header_today">
            <font class="days">$i</font>
          </div>
EOD;
    }

 

If I remove the if statement and choose one chunk of code or the other to execute, the calendar works fine. It's all in the if statement but i don't see anything wrong.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/161063-solved-heredoc-causing-problems/
Share on other sites

remove the white space after the first EODl

'EOD;    '

should be

'EOD;'

(excluding the quotes)

 

EDIT: full code

    if (($i == date("j")) && ($month == date("m")) && ($year == date("Y"))) {
      $EventEOD .=<<<EOD
        <td width="110px" height="103px" valign="top" align="center">
          <div class="date_header_today">
            <font class="days_today">$i</font>
          </div>
EOD;
    } else {
      $EventEOD .=<<<EOD
        <td width="110px" height="103px" valign="top" align="center">
          <div class="date_header_today">
            <font class="days">$i</font>
          </div>
EOD;
    }

 

Note how else is green on mine (due to correct parsing)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.