Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.