替换符号。= php

时间:2014-03-05 08:36:00

标签: php xenforo

你好,我有这个代码:

  $thread_qry5= "SELECT * FROM xenProve_prove ORDER BY view_count DESC LIMIT 5";

                                    $row5 = XenForo_Application::get('db')->fetchAll($thread_qry5);

                                    foreach ( $row5 AS $rows5 ) {
                                        $viewid = $rows5['thread_id'];
                                        $viewtitle = $rows5['title'];
                                        $viewuser = $rows5['username'];

                                          $MostView .= 'div style="height:30px; width:640px; border-bottom:1px solid #999;padding:5px;">
                                                  <div style="height:40px; width:500px;float:left">
                                                      <div style="height:20px; width:650px; font-size:16px;color:#6d3f03;">'.$viewtitle.'</div>
                                                      <div style="height:20px; width:650px; font-size:12px;color:#6d3f03;">'.$viewuser.'</div>
                                                  </div>
                                          </div>';

如何替换此符号。=? Xenforo系统不读取此符号(。=) 我试过了:

 $MostView = 'div style="height:30px; width:640px; border-bottom:1px solid #999;padding:5px;">
                                                  <div style="height:40px; width:500px;float:left">
                                                      <div style="height:20px; width:650px; font-size:16px;color:#6d3f03;">'.$viewtitle.'</div>
                                                      <div style="height:20px; width:650px; font-size:12px;color:#6d3f03;">'.$viewuser.'</div>
                                                  </div>
                                          </div>' . $MostView;

但不起作用。 我尝试了For循环anche while循环但不起作用。 谢谢你

1 个答案:

答案 0 :(得分:2)

您正在尝试将字符串添加到另一个不存在的字符串(由concatenating assignment operator)。您必须先定义字符串:

$MostView = '';

然后:

foreach ( $row5 AS $rows5 ) {

    $viewid = $rows5['thread_id'];
    $viewtitle = $rows5['title'];
    $viewuser = $rows5['username'];

    $MostView .= 'div style="height:30px; width:640px; border-bottom:1px solid #999;padding:5px;">
                                              <div style="height:40px; width:500px;float:left">
                                                  <div style="height:20px; width:650px; font-size:16px;color:#6d3f03;">'.$viewtitle.'</div>
                                                  <div style="height:20px; width:650px; font-size:12px;color:#6d3f03;">'.$viewuser.'</div>
                                              </div>
                                      </div>';

我不认为这个问题与XenForo有关。如果您打开错误报告(只需检查Google或Stack Overflow),您将获得有关此错误的更多有用信息。