dqp21271 2017-03-31 13:46
浏览 43
已采纳

PHP意外的文件结束发生在在线测试环境中,但在开发环境中不会发生

After I pulled the last code updates to an AWS instance where a test environment is running, a page displayed HTTP Error 500. I'm using CodeIgniter and the AWS instance was set to run as "production" (SetEnv CI_ENV production on .htaccess), so I changed that to "development" to display PHP error messagens. That's when I get the following mesage.

An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected end of file

Filename: /var/www/html/flip/application/views/flip_list.php

Line Number: 58

Backtrace:

File: /var/www/html/flip/application/controllers/Flip.php Line: 131 Function: view

File: /var/www/html/flip/index.php Line: 315 Function: require_once

On my localhost environment it does not happen, the page is displayed without errors or warnings.

Localhost is running PHP 7.0.15-0ubuntu0.16.04.4. And the AWS instance is running PHP 7.0.14 on CentOS. CodeIgniter version is 3.1.3.

I checked flip_list.php and Flip.php, but I didn't find where the problem is.

The controller file (Flip.php) is 350+ lines long, so I'm posting it on a pastebin: https://pastebin.com/agyMuf1T

Below the code of the view (flip_list.php):

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php
$first = true;
$second = false;
foreach ($editions->result() as $edition) {
    $edition_hash = $this->flip->encrypt_decrypt_edition_id($edition->edition_id, 'encrypt');

    $date = date_create($edition->edition_date);
    $date = date_format($date, 'd\/m\/Y');

    if( $first ) {
        $first = false;
        $second = true;
    ?>
    <div class="latest">
        <div class="item">
            <a href="<?php echo base_url('flip/'.$slug.'/view/'.$edition_hash); ?>" class="view-edition">
                <img src="<?php echo $edition->edition_cover; ?>" class="edition-cover">
                <span>Edição <?php echo $date; ?></span>
                <span>Número <?php echo $edition->edition_number; ?></span>
            </a>
        </div>
    </div>
    <?php
    }
    else {
    if( $second ) { 
        $second = false;
    ?>
    <div class="editions">
    <div class="d-flex flex-row align-content-stretch flex-wrap">
    <?
    }
    ?>
        <div class="item">
            <a href="<?php echo base_url('flip/'.$slug.'/view/'.$edition_hash); ?>" class="view-edition">
                <img src="<?php echo $edition->edition_cover; ?>" class="edition-cover">
                <span><?php echo $date; ?></span>
            </a>
        </div>
    <?php
    }
} // foreach
?>
    </div><!-- .d-flex -->
    </div><!-- .editions -->

I'd like some help debbuging this. Thanks!

  • 写回答

2条回答 默认 最新

  • doumaogui5937 2017-03-31 13:55
    关注

    You probably have short tags (http://php.net/manual/en/language.basic-syntax.phptags.php) disabled on your test server. You have two choices, enable short tags in your php.ini or change <? to <?php. It's generally not considered great practice to use short tags, and errors like this are one reason why, so I'd suggest changing your tags to use <?php.

    I'll post part of the view which has your short tag:

     <div class="editions">
        <div class="d-flex flex-row align-content-stretch flex-wrap">
        <?
        }
        ?>
            <div class="item">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c