【问题标题】:can you customise the maximum execution time error message可以自定义最大执行时间错误信息吗
【发布时间】:2020-08-06 11:21:17
【问题描述】:

是否可以自定义最大执行时间而不是显示

PHP Fatal Error – yii\base\ErrorException

最大执行时间超过 30 秒

然后在错误页面上显示所有代码,我希望它带您到自定义错误页面,上面写着“您需要添加一些搜索条件以减少返回的记录数”

或类似的东西。我正在使用 Yii2 和 PHP

我的站点控制器中有以下操作

public function actions()
{
    return [
        'error' => [
            'class' => 'yii\web\ErrorAction',
        ],
        'captcha' => [
            'class' => 'yii\captcha\CaptchaAction',
            'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
        ],
    ];
}

我有一个名为views/site/error.php的页面

<div class="alert alert-danger" style="font-size: 14pt; text-align: center;">
    <?= nl2br(Html::encode($message)) ?>
</div>

<p>
    Please contact Client Support team if you think this is an error with our servers.
</p>

<?= Html::a('Back', Yii::$app->request->referrer, ['class' => 'btn btn-info']) ?>
<?= Html::a('Home', ['/'], ['class' => 'btn btn-success']) ?>

但是如果从来没有因为执行时间错误进入这个页面

不确定我做了什么,但它现在确实进入了自定义错误页面,但它仍然在我的自定义消息下方显示代码

所以有没有办法摆脱我的自定义消息下方的信息。除了上面代码中的内容之外,我的 error.php 上没有其他内容

【问题讨论】:

    标签: php yii2 execution-time


    【解决方案1】:

    经过进一步调查,我发现它转到了另一个页面 execption.php 而不是 error.php,它在文本下方显示了完整的错误。所以我现在设法对其进行了排序:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 2011-02-10
      • 2019-08-03
      相关资源
      最近更新 更多