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 200 views
2 answers 202 views
2 answers 235 views
4 answers 491 views
3 answers 319 views
...