Thinkphp 3.2 Opening Cache cache considerations, filtering illegal characters

Source: Internet
Author: User
Tags php source code

Open the cached configuration file/application/common/conf/cache.php source code is as follows:

<?phpreturn Array(    //'Configuration Items' = 'Configuration Values'    ' layout_on '=true,    ' html_cache_on '=Strpos($_server[' Http_host '], '. ') !== false, // turning on static caching defaults totrueLocal does not open    ' Html_cache_time '=3600, // global Static cache validity period (seconds)    ' Html_file_suffix '='. shtml ', // set the static cache file suffix    ' Html_cache_rules '=Array(        ' * '=Array(' {: Module}/{:controller}/{:action}/{$_server. REQUEST_URI|MD5} ', 3600, ' TRIMSW '),    ));

Note: the TRIMSW behind is to remove all non-/\w strings, preventing certain system errors from entering special characters such as Chinese.

The source of the function TRIMSW:

/** * @author [email protected] * @descriptionremove spaces and non-\wstring that is used toCacheConfiguration * * @param$str * @paramstring $emptyValue * * @returnmixed|string */functionTRIMSW ($str, $emptyValue= ' _empty_ '){    $str= Preg_replace('/([^\w\/]+)/', '-', $str);    if(Empty($str)) {        $str= $emptyValue;    }    return$str;}





Thinkphp 3.2 Opening Cache cache considerations, filtering illegal characters

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.