【问题标题】:Syntax error, unexpected end of file in C:\xampp\htdocs\febi\application\views\agenda_right.php on line 22语法错误,第 22 行 C:\xampp\htdocs\febi\application\views\agenda_right.php 中的文件意外结束
【发布时间】:2012-08-06 16:09:25
【问题描述】:
<li class="last">
            <h2>Info Penerimaan Mahasiswa Baru 2012/2013</h2>
            <div class="imgholder"><img src="<?php echo base_url().'images/'; ?>0708111913_maba.jpg" alt="mahasiswa baru" style="width:240px;height:130px;" /></div>
            <?php
                                if ($ag_2->num_rows() == 0)
                                {
                                        echo "Tidak ada agenda";
                                }
                                else
                                {
                                $row = $ag_2->row();
                                $texts = $row->texts;
                                $postname = $row->postname;
                                echo word_limiter ($texts, 30);
                        ?>
                        <p class="readmore"><a href="<?php echo base_url().index_page().'/post/read/'.$postname; ?>">Baca selengkapnya &raquo;</a></p>
                        <?
                        }?>
                        </li>
        </ul>
        <br class="clear" />
    </div>

【问题讨论】:

  • 我认为你的img 标签可能搞砸了
  • “文件意外结束”通常是缺少一个或多个大括号。在这种情况下,可能是因为服务器禁用了short_open_tag,您需要编写&lt;?php } ?&gt; 而不仅仅是&lt;? } ?&gt;
  • 试试&lt;img src="&lt;?php echo base_url().'images/0708111913_maba.jpg' ?&gt;" alt="mahasiswa baru" style="width:240px;height:130px;" /&gt;
  • 短标签已启用?就在列表元素 }?> 结束之前
  • @Blaine 你错过了 src 末尾的 "

标签: php codeigniter syntax-error


【解决方案1】:

就像 DaveRandom 和 Blaine 所说,尝试以下任一方法:

  • &lt;? 替换为&lt;?php
  • 启用short_open_tag(请参阅answer here 在XAMPP 中执行此操作)

【讨论】:

  • 重点应该放在用&lt;?php 替换&lt;? - 启用short_open_tag 可能会适得其反,因为它只是意味着当您将代码移动到其他不存在的地方时,它会再次中断'没有启用它。
  • @Dustin - 你知道你刚刚批准了一个错误地将with 格式化为代码的编辑,并删除了一个有效的超链接? stackoverflow.com/suggested-edits/342324
猜你喜欢
  • 1970-01-01
  • 2013-09-13
  • 2016-02-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-01
  • 2017-09-18
  • 1970-01-01
  • 2016-12-28
相关资源
最近更新 更多