PHP example: example of special character processing function

WBOY
Release: 2016-07-25 08:52:18
Original
785 people have browsed it
This article introduces several examples of PHP functions for processing special characters, including strip_tags, htmlspecialchars, addslashes, etc. Friends in need can refer to it.

Share the usage of special character processing functions in PHP, including the usage of strip_tags, htmlspecialchars, addslashes, etc. Code:

<html>
<body>
    <?php
      if ($_POST['submitted'] == "yes"){
        $yourname = $_POST['yourname'];
        $yourname = trim ($yourname);
        $yourname = strip_tags ($yourname);
        $yourname = htmlspecialchars ($yourname);
        $yourname = addslashes ($yourname);        
        echo $yourname . "<br />";
        ?>Try Again<?php
      }
      if ($_POST['submitted'] != "yes"){
        ?>
        <form action="index.php" method="post">
          <p>例子:</p>
          <input type="hidden" name="submitted" value="yes" />
          您的名字: <input type="text" name="yourname" maxlength="150" /><br />
          <input type="submit" value="Submit" style="margin-top: 10px;" />
        </form>
        <?php
      }
    ?>
  </div>
</body>
</html>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template