How to parse CKEditor content through PHP htmlspecialchars

Home > Search > How-to
  by

CKEditor will change the opening bracket character < to the markup &lt; and closing bracket character > to &gt;.  For example, if <input type="text"> is placed inside of a CKEditor code snippet, &lt;input type="text"&gt; will br produced. This will cause problems with CKEditor and the web page.

 As an example, let's say you are using PHP to retrieve data from a column named content in a SQL database.

<?php
   $content = $row["content"];
?>

 

The PHP htmlspecialchars function can be used to fix the problem where CKEditor changes certain special characters to HTML. 

<?php
   $content = htmlspecialchars($row["content"], ENT_QUOTES);
?>

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments