【发布时间】: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