How to configure errno in thinkphp

Updated on technology 2024-04-17
7 answers
  1. Anonymous users2024-02-07

    By default, thinkphp displays the system's default error page when an error occurs, and when it is officially launched, in order to unify the user experience, we can customize our own error page, there are usually two ways:

    1. Customize the system error page template.

    The default error template is located at: thinkphp tpl think

    We only need to modify the tmpl exception file configuration parameter in the project and respecify the error template.

    tmpl_exception_file'=> Define a common error template.

    e['file'] exception file name.

    e['line'] The number of file lines where the exception occurred.

    e['message'] Exception information.

    e['trace'] Detailed trace information of the exception.

    Because the exception template uses native PHP**, it can also support the use of any PHP method and system variable.

    2. Set up the wrong redirect page.

    If you want to be redirected to a specified URL instead of reading the error template when an error occurs, we can also set the error page parameter directly.

    error_page'=>'/public/'Define the URL of the error redirection page.

    Note that the page to which the error page points can no longer use the exception template variable.

  2. Anonymous users2024-02-06

    ThinkPHP has a debugging mode that is specially set for the development process, and when the debugging mode is turned on, it will sacrifice a certain amount of execution efficiency, but the convenience and debugging features brought by it are well worth it.

    This can be set in the portal file.

  3. Anonymous users2024-02-05

    $value = c('The value of the key in the configuration file');

    config = array();

    config['db_name'] = 'mysql';

    config['db_pwd'] = '123123';

    c($config);If the first argument of the c method is passed into the array, it means a batch assignment, and the above assignment is equivalent to:

    c('db_name',1);

    c('db_pwd',1);

    userid = c('db_name');Get the parameter $usertype = c('db_pwd');To get the parameters of the set.

  4. Anonymous users2024-02-04

    The first thing to do is to build the module under the lib action.

    The content is as follows: Copy** **As follows:

    author rocky

    date 20141021

    DESC empty module 404 and other errors.

    class emptyaction extends commonaction {

    function _empty(){

    header("http/ 404 not found");

    this->display('public:404');

    2. After the above processing, the 404 page can only be accessed when the empty module is accessed, so in order to access the empty method and also access the 404 page, we also need to add an empty method, the method is as follows:

    Copy ** ** As follows:

    Handle all the methods that don't have them, leading to the 404 page.

    public function _empty()

    r('empty/_empty');

    3. It's basically okay to do the above work, but don't forget to put your page under TPL Public.

  5. Anonymous users2024-02-03

    IIS environment.

    If your server environment supports ISAPI Rewrite, you can configure the file and add the following:

    Below the later version of IIS, it can be configured to add a rewrite node in the middle:

    nginx environment.

    In earlier versions of nginx, pathinfo is not supported, but it can be achieved by configuring the **rule in :

    location / { // ….Omit part**.

    if (!e $request_filename) {

    break;

    In fact, the internal is ** to the URL of the compatibility mode provided by thinkphp, and in this way, you can solve other web server environments that do not support pathinfo.

    If your thinkphp is installed in a secondary directory, Nginx's pseudo-static method is set as follows, where YouDomain is the name of the directory where it is located.

    location /youdomain/ {

    if (!e $request_filename){

  6. Anonymous users2024-02-02

    Define constants directly in the conf directory.

  7. Anonymous users2024-02-01

    To enable the debug mode, you only need to define a constant in the main entry file.

    Then define a parameter in the configuration file to enable the page trace display information, as follows:

    show page trace' =true, enable page trace

    This has been configured, after turning on the debugging mode, the project will load the default file under the conf directory of the thinkphp core package, you can also customize one under your project configuration directory, so that you can override the default file in the core package, let's take a look at what parameters are configured by default.

    return array(

    log_record'=>true, which is logged into the Wangran line.

    log_exception_record' =

    true, whether to log exception information.

    log_level' =

    emerg,alert,crit,err,warn,notic,info,debug,sql', the log level at which logging is allowed.

    db_fields_cache'=>false, field cache information.

    tmpl_cache_on' =

    false, whether to enable template compilation caching, set to false, it will be recompiled every time.

    tmpl_strip_space' =

    false, whether to remove HTML spaces and line breaks from the template file.

    show_error_msg' =

    true, an error message is displayed.

    The parameters inside can be defined by yourself,There is an app file case inside to check the case of the file name Lupi is very important,That is, simulate the Linux platform under Windows,Because the Linux environment is case-sensitive,And now there are many PHP virtual hosts that accompany the Lingling are Linux environments,So turning on this parameter is of great help to our cross-platform porting,When you turn on the debugging mode and page trace, Go to the display template and see what the page is different about.

Related questions
13 answers2024-04-17

Now the mainstream configuration, but the motherboard 3-wire brand is recommended to change to a 1-wire more reliable, such as ASUS.

3 answers2024-04-17

executable file,You can double-click to install it.,Just remember the installation directory and it's OK.,Because you'll need this installation directory later.。 If it is a compressed package, you just need to remember the location after decompression; The following figure shows the contents of the decompressed file; >>>More

10 answers2024-04-17

CPU: Intel E5300 470 yuan.

Motherboard: Spartak P45 Kuroshio series 485 yuan. >>>More

5 answers2024-04-17

Method steps.

The first step is to open the Environment Variable Configuration window. Right-click on the computer, Properties - Advanced System Settings - Environment Variables. >>>More

5 answers2024-04-17

I sell computers, and to be honest, it's not enough to be a server. (Except for Legendary Private Servers). >>>More