Parameter filtering-PHP source code

Source: Internet
Author: User
PHP code for parameter filtering

 ** @ Param string $ string the string to be converted * @ return string */static public function nl2br ($ string) {return nl2br ($ string);}/*** set
Convert to \ n ** @ param string $ string to be converted * @ return string */static public function br2nl ($ string) {$ array = array ('
','
'); Return str_replace ($ array, "\ n", $ string );} /*** multiple consecutive spaces are reserved for only one ** @ param string $ string to be converted * @ return unknown */static public function merge_spaces ($ string) {return preg_replace ("/\ s (? = \ S)/"," \ 1 ", $ string);}/*** multiple consecutive
Only one ** @ param string $ string to be converted * @ return string */static public function merge_brs ($ string) {return preg_replace ("/(( ) +)/I ","
", $ String );} /*** filter the html tag in the string ** @ param string $ string the string to be converted * @ return string */static public function strip_tags ($ string) {return strip_tags ($ string );} /*** convert the string to all lowercase letters ** @ param string $ string the string to be converted * @ return string */static public function strtolower ($ string) {return strtolower ($ string );} /*** convert the string to uppercase ** @ param string $ string the string to be converted * @ return string */static public function strtoupper ($ string) {return strtoupper ($ string );} /*** filter specific characters starting and ending with a character string ** @ param string $ string to be converted * @ param string $ char_list list of specific characters to be converted * @ return string */static public function trim ($ string, $ char_list = '\\\\ s') {$ chars = preg_replace (array ('/[\ ^ \-\] \\\]/S ', '/\ {4}/S','/\/'), array (' \ 0 ','\\', '\/'), $ char_list); $ pattern = '^ ['. $ chars. '] * | ['. $ chars. '] *; return preg_replace ("/$ pattern/sSD", '', $ string );} /*** filter the carriage return and line feed in the string ** @ param string $ string the string to be converted * @ return string */static public function strip_new_lines ($ string) {return str_replace (array ("\ n", "\ r"), '', $ string );} /*** filter the script in the string ** @ param string $ string the string to be filtered * @ return string */static public function strip_script ($ string) {$ reg = "/ ] *?>. *? <\/Script>/is "; return preg_replace ($ reg,'', $ string);}/*** filter strings

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.