thinkphp Empty Operation Empty module

Source: Internet
Author: User

Empty operation and empty module is very useful, he has some similar to PHP virtual machine Custom 404 page, using this mechanism we can better implement the URL and error page optimization.

One. Empty module:

? Well understood, that is, when you do not have the module, thinkphp will automatically find the module, when the module is not found, thinkphp will automatically define the index method under the empty module.

<? PHP              class extends controller{                        publicfunction  index () {                               echo ' <script> Window.location.href= ". /er/error "</script>";?                }

? This is a simple empty module that can be developed according to the requirements of the project

Two. Empty operation:

Empty operation is, when you in the current module, the implementation of the module does not have a method, will automatically jump to _empty this method, and can be used in conjunction with the empty module.

For example, an empty operation is defined under the index module

<? PHP            class indexcontroller extendx controller{                      publicfunction  index () {?                               Echo "Index function";                      }                        Public function _empty () {                              echo ' <script>window.location.href= '. /er/error "</script>";?                   }?

OK, here it is! More complex will be specific to the concrete analysis of the matter!!

thinkphp Empty Operation Empty module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.