SWITCH语句语法错误

时间:2016-08-10 11:49:00

标签: php if-statement switch-statement

我收到此错误: Parse error: syntax error, unexpected '', expecting endswitch (T_ENDSWITCH) or case (T_CASE) or default (T_DEFAULT) in /var/www/mel-suhaib/application/modules/default/views/scripts/user/user.phtml on line 244

<?php switch ($ext): ?>

                     line244++>     <?php case  "pdf": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "docx": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "zip": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "xlsx": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "pptx": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "rar": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "xls": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "jpg": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "ppt": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "doc": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case  "3gp": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "mp4": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php case "png": ?>
                                    <img class="timeline-img pull-left" src="../../assets/admin/pages/media/blog/2.jpg" alt="">
                                    <?php break; ?>
                                    <?php endswitch; ?>

1 个答案:

答案 0 :(得分:0)

解决了我应该说:

<?php switch ($ext): case "pdf": ?>

而不是

<?php switch ($ext): ?> <?php case "pdf": ?>