logo
Blog single photo

What is the use of htmlentities() function in php


                        

Try out following example

 <?php   
      if(isset($_POST['save'])){  
           $htmltext1=$_POST['htmltext1'];  
           $htmltext2=htmlentities($_POST['htmltext2']);  
           }  
           ?>  
 <form method="post" action="">  
 <textarea name="htmltext1"></textarea>  
 <textarea name="htmltext2"></textarea>  
 <input type="submit" name="save">  
 </form>  
 <p>First content </p>   
 <?php   
      if(isset($_POST['htmltext1'])){  
      echo $htmltext1;  
      }  
 ?>  
 <p>2nd content </p>   
 <?php   
      if(isset($_POST['htmltext2'])){  
      echo $htmltext2;  
      }  
 ?>  
Top