0

I have problem with single or double quotes. I was read here some benefits of using single and double quotes, and i know different. My problem is next. Why can i use double quotes inside text input and it is echo success.

This is my form.

echo "<form action=\"display.php\" method=\"POST\">";
echo "<input type=\"text\" name=\"text\">";
echo "<input type=\"submit\" value=\"display\">";

My display.php

 $word = $_POST['text'];
 echo $word;

My question is. Why is double quotes allowed in input? In my head,i think that if double quote come inside text input then we have 3 duoble quote and parser will not know where is end of string? i know what is escaping for database, but i ask for this case. Thanx

Qirel
  • 25,449
  • 7
  • 45
  • 62
  • use one quote in double quote for example `""` – Naumov Jun 08 '16 at 17:13
  • the `\\ ` before the `"` 'escapes' that double quote, so the parser knows he should not interpret it as end of string. – Jeff Jun 08 '16 at 17:18
  • 1
    Yes, it will become a problem if you just take in input containing a double quote value and straight use it as the value for your input (). You end up with broken html unless you use something like htmlspecialchars() in php to convert stuff like double quotes into html entities when outputting them. – georaldc Jun 08 '16 at 17:42

0 Answers0