引用问题文本框

Sha*_*aun 1 html php

我有一个文本框,

<!--<input type="text"  maxlength="255" name="$key" value="<?php echo $value;?>"  />-->
Run Code Online (Sandbox Code Playgroud)

$ value是b'bbb"bbb

但它只显示b'bbb为值.可以帮助???

Lek*_*eyn 5

使用以下方法正确转义应在HTML中显示未解析的数据htmlentities():

<input type="text"  maxlength="255" name="<?php echo htmlentities($key);?>" value="<?php echo htmlentities($value);?>"  />
Run Code Online (Sandbox Code Playgroud)

引号char(")破坏了你的代码.如果你$value喜欢它会变得更危险"><script>alert("xss")</script>(它叫做XSS并会弹出一个带有"xss"的警告框)