How PHP preserves multiple spaces and wraps text styles when submitting a form

Source: Internet
Author: User
Here is a small series to bring you a PHP submission form when you keep multiple spaces and text style wrapping method. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.

requirements are: the ability to mask sensitive words when a user submits a form. Sensitive words from the server side of the same path under the ciku.txt, sensitive words through the "|" connections, such as "g|c|a", replace sensitive words when submitting a form, and more importantly, you need to maintain the style of multiple spaces and line breaks that users enter in the form's text field and output them as-is. The PHP code is as follows:

<?phpheader ("Content-type:text/html;charset=utf-8"), if ($_post) {  $pattern = array (        '//',//half-width space        '/ /',//full-width space        '/\r\n/',//window under line-break        '/\n/',//linux,unix under line-break character     ;  $replace = Array (' ', ' ', ' <br/> ');  $message =preg_replace ($pattern, $replace, $_post[' message ');   $cikuStr =file_get_contents (' ciku.txt ');  $CIKUARR =explode (' | ', $CIKUSTR);  $liuyan =str_replace ($CIKUARR, "* *", $message);  Echo ' Your message is:<br> '. $liuyan;}? >

1<!--This is the form page code--<body>  <form name= "Message_board" id= "Message_board" method= "POST" action= " timu.php ">     <textarea name=" message "id=" message "cols=" "rows=" > "http://www.cnblogs.com/ph pdream/"---Yong Quan  </textarea><br/>     <input type=" Submit "value=" Submission message "id=" Submitmessage " onclick=/>  </form></body>

The effect is as follows:


Related Article

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.