How does php define a filter like Java web?

Source: Internet
Author: User
: This article mainly introduces how php defines filters like JavaWeb. For more information about PHP tutorials, see. Php verifies user login in a unified manner to prevent user input links from entering some website interfaces in the unlogged status

We know that the filters in php only filter data input. they do not intercept certain url filters like the Java Servlet technology, so that before the requests come, and before sending them, requests and outputs can be processed freely and transparently, and can be forwarded at the same time. the function is quite powerful. most Java filters recognize filters through the examples of character encoding filtering, then, a large number of filters are used in the actual project, which is very powerful. at the same time, the Java MVC framework uses filters for forwarding and defines various processing methods, but php does not seem to have any, I am using the ThinkPhp framework, but this framework is not provided, but I think this problem is not difficult, so I wonder if there is a setting, or in some places, any request passes through it. I want to find it in the thinkphp framework, but it is time-consuming and there are other projects that do not have time. So I came up with a solution on the Internet,

In the PHP configuration file php. in the INI file, auto_prepend_file = "a file" is set to add this file before each php file. it is usually a php file and I add a filter. php: Put this file in php. filter. the content of php is

$ Url = $ _ SERVER ["PHP_SELF"]; $ url = substr ($ url, strlen ($ url)-8, 2); // echo $ url; if ($ _ SERVER ["PHP_SELF"] = '/miaomi/index. php/Index/login ') | ($ _ SERVER ["PHP_SELF"] ='/miaomi/index. php ') | $ url = 'in') {} else {SESSION_START (); if ((! Isset ($ _ SESSION ['username']) {echo"

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.