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 290 views
2 answers 342 views
2 answers 373 views
4 answers 702 views
3 answers 455 views
...