<noframes id="tldpt"></noframes>
  • <thead id="tldpt"><acronym id="tldpt"><video id="tldpt"></video></acronym></thead>
    \n
    \n

    404<\/h1>\n

    Page not found<\/p>\n \">Go back home<\/a>\n <\/div>\n<\/body>\n<\/html><\/pre>

    Here we use a simple and beautiful design to display the theme of the 404 page and buttons. <\/p>\n

    1. Test<\/li><\/ol>\n

      We can access a non-existent route at will, for example, visit http:\/\/yourdomain.com\/abc, and you can see our newly created one. Beautiful 404 page. <\/p>\n

      1. Customize the 404 page<\/li><\/ol>\n

        If you want to add more content or adjust the style of the 404 page, you only need to modify the view file. We can customize the 404 page according to actual needs, such as adding search functions, contact information, etc. At the same time, if you are worried about browser caching affecting the display effect, you can solve it by introducing CSS and JS files into the view page. <\/p>\n

        1. Summary<\/li><\/ol>\n

          In this article, we introduced how to use ThinkPHP6 to implement a beautiful 404 page. By creating routes, controllers, and views, we can easily build a 404 page that meets our needs. In actual development, the 404 page is an important user experience factor, and we should pay attention to its design and beautification. <\/p>"}

          亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

          Home PHP Framework ThinkPHP Use ThinkPHP6 to implement a beautiful 404 page

          Use ThinkPHP6 to implement a beautiful 404 page

          Jun 20, 2023 am 11:06 AM
          thinkphp page beautify

          With the increasing development of the Internet, many websites or applications have gradually become more complex. When users use it, they often encounter error pages, the most common of which is the 404 page. The 404 page means that the page being accessed does not exist and is a common error page. For websites or applications, a beautiful 404 page can greatly improve the user experience. In this article, we will introduce how to use ThinkPHP6 to quickly implement a beautiful 404 page.

          1. Create route

          First, we need to create an error.php file in the route folder, define a route in it, and point the error page to our new Error index method in the controller. The code is as follows:

          <?php
          use thinkacadeRoute;
          
          Route::rule('/404', 'error/index')->name('404');

          It should be noted that here we name the route 404 to facilitate calling later.

          1. Create controllers and views

          Create a new Error.php file in the controller folder, the code is as follows:

          <?php
          
          namespace appindexcontroller;
          
          use thinkController;
          
          class Error extends Controller
          {
              public function index()
              {
                  return $this->fetch('error/404');
              }
          }
          

          Here we inherit the Controller class , and return the newly created 404 view in the index method.

          Create a new error folder in the view folder and create the 404.html file in it. The code is as follows:

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>404 Not Found</title>
              <style>
                  body {
                      background-color: #eee;
                      text-align: center;
                      font-family: 'Microsoft YaHei', sans-serif;
                  }
                  .container {
                      margin-top: 10%;
                  }
                  h1 {
                      font-size: 8em;
                      color: #ddd;
                      margin-bottom: 0;
                  }
                  p {
                      font-size: 3em;
                      color: #777;
                      margin-top: 0;
                  }
                  a {
                      text-decoration: none;
                      color: #000;
                      border: 1px solid #000;
                      padding: 10px 20px;
                      margin-top: 30px;
                      display: inline-block;
                  }
                  a:hover {
                      border-color: #777;
                  }
              </style>
          </head>
          <body>
              <div class="container">
                  <h1>404</h1>
                  <p>Page not found</p>
                  <a href="<?php echo url('/') ?>">Go back home</a>
              </div>
          </body>
          </html>

          Here we use a simple and beautiful design to display the theme of the 404 page and buttons.

          1. Test

          We can access a non-existent route at will, for example, visit http://yourdomain.com/abc, and you can see our newly created one. Beautiful 404 page.

          1. Customize the 404 page

          If you want to add more content or adjust the style of the 404 page, you only need to modify the view file. We can customize the 404 page according to actual needs, such as adding search functions, contact information, etc. At the same time, if you are worried about browser caching affecting the display effect, you can solve it by introducing CSS and JS files into the view page.

          1. Summary

          In this article, we introduced how to use ThinkPHP6 to implement a beautiful 404 page. By creating routes, controllers, and views, we can easily build a 404 page that meets our needs. In actual development, the 404 page is an important user experience factor, and we should pay attention to its design and beautification.

          The above is the detailed content of Use ThinkPHP6 to implement a beautiful 404 page. For more information, please follow other related articles on the PHP Chinese website!

          Statement of this Website
          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

          Hot AI Tools

          Undress AI Tool

          Undress AI Tool

          Undress images for free

          Undresser.AI Undress

          Undresser.AI Undress

          AI-powered app for creating realistic nude photos

          AI Clothes Remover

          AI Clothes Remover

          Online AI tool for removing clothes from photos.

          Clothoff.io

          Clothoff.io

          AI clothes remover

          Video Face Swap

          Video Face Swap

          Swap faces in any video effortlessly with our completely free AI face swap tool!

          Hot Tools

          Notepad++7.3.1

          Notepad++7.3.1

          Easy-to-use and free code editor

          SublimeText3 Chinese version

          SublimeText3 Chinese version

          Chinese version, very easy to use

          Zend Studio 13.0.1

          Zend Studio 13.0.1

          Powerful PHP integrated development environment

          Dreamweaver CS6

          Dreamweaver CS6

          Visual web development tools

          SublimeText3 Mac version

          SublimeText3 Mac version

          God-level code editing software (SublimeText3)

          Hot Topics

          PHP Tutorial
          1488
          72
          How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

          Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

          How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

          To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

          There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

          ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

          How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

          Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

          Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

          Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

          How to quickly refresh a web page? How to quickly refresh a web page? Feb 18, 2024 pm 01:14 PM

          Page refresh is very common in our daily network use. When we visit a web page, we sometimes encounter some problems, such as the web page not loading or displaying abnormally, etc. At this time, we usually choose to refresh the page to solve the problem, so how to refresh the page quickly? Let’s discuss the shortcut keys for page refresh. The page refresh shortcut key is a method to quickly refresh the current web page through keyboard operations. In different operating systems and browsers, the shortcut keys for page refresh may be different. Below we use the common W

          How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

          ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

          How is the performance of thinkphp? How is the performance of thinkphp? Apr 09, 2024 pm 05:24 PM

          ThinkPHP is a high-performance PHP framework with advantages such as caching mechanism, code optimization, parallel processing and database optimization. Official performance tests show that it can handle more than 10,000 requests per second and is widely used in large-scale websites and enterprise systems such as JD.com and Ctrip in actual applications.

          See all articles