Tsallaka zuwa abun ciki
Justice Tech School

Escaping Output

htmlspecialchars stops XSS by turning < and > into entities. Escape on output.

Example
echo htmlspecialchars("<script>alert(1)</script>");

Result

&lt;script&gt;alert(1)&lt;/script&gt;

Exercise

Escape HTML.

($s)

Quiz Test

Why escape output?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.