PHP语法错误:字符串“</ div>”后出现意外

I been trying to figure out if I can add a for loop in this situation:

$g = '<td id="'.$this->currentDate.'" class=" td-top-text '.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).
                ($cellContent==null?'mask':'').'">'
                //if statement 
                .($this->currentDate === $tutor_date ? 
                    '<div class="inside">'//open inside
                        .'<div class="inside-content">' //open inside-content
                           . '<div class="inside-date">'.$cellContent.'</div>'//open and close inside-date



                             for($i =0; $i < count($appt_date['date']); $i++) {
                               '<div class="inside-event '.$bkg_color.' ck-button btn-xs" title="Group Session">'//open inside-event
                                   . '<label class="label-for-text">'//open label
                                       . '<input type="radio" data-toggle="modal" data-target="#myModal" name="appt_selected" value="'.$tutor_shedule_id.'" >'//open input
                                           . '<span>'.$tutor_info.'</span>' //open and close span
                                       .'</input>'// close input    
                                   . '</label>'// close label
                               . '</div>';//close inside-event
                           }


                           '</div>'//close inside-content
                       . '</div>'//close inside
                . '</td>' //close td


                //else
                : '<div class="inside">'.$cellContent.'</div>'
                  . '</td>' );

  return $g;

I tried so many things such as added a ; at the end of </div> and before the for loop, I also added a . before the for loop and after.

EDIT:

Instead of down-vote this question, please provide some feedback and let me know what is wrong. For me this code is "fine" until you tell me a better way to do it. So, please I really appreciated your feedback.

Thanks.

I recommend you to do the if-else statement rather than this approach as this process is very difficult to debug. So, go with the following code:

    $g = '<td id="'.$this->currentDate.'" class=" td-top-text '.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).
            ($cellContent==null?'mask':'').'">';

            if ($this->currentDate === $tutor_date){ 

                $g.='<div class="inside">'//open inside
                    .'<div class="inside-content">' //open inside-content
                       . '<div class="inside-date">'.$cellContent.'</div>';//open and close inside-date



                         for($i =0; $i < count($appt_date['date']); $i++) {
                           $g.='<div class="inside-event '.$bkg_color.' ck-button btn-xs" title="Group Session">'//open inside-event
                               . '<label class="label-for-text">'//open label
                                   . '<input type="radio" data-toggle="modal" data-target="#myModal" name="appt_selected" value="'.$tutor_shedule_id.'" >'//open input
                                       . '<span>'.$tutor_info.'</span>' //open and close span
                                   .'</input>'// close input    
                               . '</label>'// close label
                           . '</div>';//close inside-event
                       }



                      $g.= '</div>'//close inside-content
                   . '</div>'//close inside
            . '</td>' ;//close td

            }else{

             $g.='<div class="inside">'.$cellContent.'</div>'
              . '</td>'; }

  return $g;

Well that was painful, I've tried to fix it up a little and at least make it more readable. Have a try of this... also I should point out I'm pretty sure this code is vulnerable to XSS attacks.

// Work out the Class names.
$classNameOne = ($cellNumber % 7) == 1 ? ' start '
                                       : ($cellNumber % 7) == 0 ? ' end'
                                                                : ' ';
$classNameTwo = ($cellContent == null) ? 'mask'
                                       : '';
// Build up the html.
$html = '<td id="' . $this->currentDate . '" class="td-top-text ' . $classNameOne .  $classNameTwo . '">';

if ($this->currentDate === $tutor_date) {
    $html .= '<div class="inside">';
    $html .= '<div class="inside-content">';
    $html .= '<div class="inside-date">' . $cellContent . '</div>';

    $dateInstances = count($appt_date['date']);
    for ($i = 0; $i < $dateInstances; $i++) {
        $html .= '<div class="inside-event ' . $bkg_color . ' ck-button btn-xs" title="Group Session">';
        $html .= '<label class="label-for-text">';
        $html .= '<input type="radio" data-toggle="modal" data-target="#myModal~ name="appt_selected" value="'. $tutor_shedule_id .'">';
        $html .= '<span>' . $tutor_info . '</span>';
        $html .= '</input>';
        $html .= '</label>';
        $html .= '</div>';
    }

    $html .= '</div>';
    $html .= '</div>';
    $html .= '</td>';

} else {
    $html .= '<div class="inside">' . $cellContent . '</div>';
    $html .= '</td>';
}

return $html;