Fluid output · Question 12 of 12
A template writes <script>var name = "{user.name}";</script>. Which assessment is correct?
1 answer is correct. Hard
Show answer
Answer
- D HTML escaping does not suit JavaScript; better JSON or a data attribute
Explanation
htmlspecialchars() is meant for HTML, not for JavaScript strings. Pass values cleanly as a data attribute or JSON-encoded and read them in the script.