donglinxia1541 2016-01-20 17:28 采纳率: 0%
浏览 42
已采纳

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.

  • 写回答

2条回答 默认 最新

  • doutan2111 2016-01-20 17:44
    关注

    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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢