Home>Article>Backend Development> How to customize error page in php

How to customize error page in php

王林
王林 Original
2021-10-13 16:36:22 2380browse

php method to customize the error page: 1. Add the error page template information in the configuration file; 2. Put the configuration information into /Conf/config.php of the current model; 3. In the current model Create a Public folder in the View directory and customize the error page in it.

How to customize error page in php

The operating environment of this article: windows10 system, php 7&&thinkphp 5, thinkpad t480 computer.

ThinkPHP As a lightweight PHP development framework, it has rich documentation and is easier to use than other frameworks. Therefore, we choose thinkphp here to implement a customized error page.

ThinkPHP itself provides us with its own error page, exception page and other information prompt pages. For example, the following code will display such a prompt:

$this->error('验证码错误!');

Because the built-in page is not beautiful , so we need to customize these pages. ThinkPHP provides us with the function of customizing prompt pages.

Add the following configuration information in the configuration file:

/* 错误页面模板 */ 'TMPL_ACTION_ERROR' => MODULE_PATH.'View/Public/error.html', // 默认错误跳转对应的模板文件 'TMPL_ACTION_SUCCESS' => MODULE_PATH.'View/Public/success.html', // 默认成功跳转对应的模板文件 'TMPL_EXCEPTION_FILE' => MODULE_PATH.'View/Public/exception.html',// 异常页面的模板文件

Put this configuration information into /Conf/config.php of the current model, and then add it to the View of the current model Create a Public folder in the directory and customize error.html success.html and exception.html in it.

The following is a simple error page template:

    跳转提示  

提示信息!

秒后页面将自动跳转

立即跳转 重新登录

Effect:

How to customize error page in php

Recommended learning:php training

The above is the detailed content of How to customize error page in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn