如何从php echo中删除\“\”?

时间:2015-08-19 22:39:42

标签: html

当我在表单中输入引号并在回显中显示该数据时,它会引用这样的引号,“Text Here”。如何从引号中删除\以便它只是说“Text Here”?

代码#1

        <form action="index2.php" method="post">
    Enter Your Name: <br>
    <input type="text" name="name" placeholder="Enter Your Name Here"><br>
    Enter Custom Quote: <br>
    <input type="text" name="quote" placeholder="Exe; &quot;I had a dream&quot; "><br>
    <input type="submit" value="Send">
    </form>

代码#2

<html>
<head>
</head>
<body>
    Thank you for sending us your quote <?php echo $_POST["name"]; ?>.
    You quote was <?php echo $_POST["quote"]; ?>
</body>

1 个答案:

答案 0 :(得分:2)

如果你有PHP版本&lt; 5.4.0,那么你的问题可能与魔术引号有关,这在PHP 5.4.0中已被弃用。

使用stripslashes功能。

<body>
    Thank you for sending us your quote <?php echo stripslashes($_POST["name"]); ?>.
    Your quote was <?php echo stripslashes($_POST["quote"]); ?>
</body>

您还应该使用其他功能,例如htmlspecialchars,通过将{php}代码注入form来降低某人成功破解代码的可能性。