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 285 views
2 answers 338 views
2 answers 365 views
4 answers 697 views
3 answers 450 views
...