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 |