How to convert characters to HTML entities to prevent code injecting attack in PHP

2 Answers

0 votes
$s = htmlspecialchars("<a href='test.php'>Test</a>");
print $s; 

/*
run:

&lt;a href='test.php'&gt;Test&lt;/a&gt;
 
*/

 



answered Nov 21, 2015 by avibootz
0 votes
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

 



answered Nov 21, 2015 by avibootz

Related questions

1 answer 198 views
2 answers 199 views
2 answers 232 views
4 answers 486 views
3 answers 317 views
...