RegalCoding.com

A Programming Blog

Hello mobile user!

My first update

After making the previous post, I noticed that the line breaks and paragraphs were not being formed correctly; this was to be expected.

As a rudimentary security procedure, I have a line of code very similar to:
filter_var($content, FILTER_SANITIZE_SPECIAL_CHARS)

which serves the purpose of escaping certain characters that could pose problems if output in an unexpected manner. Although this sort of attention to security might seem a bit overkill for a script which only I am using, it is good practice in general, and limits what a malicious user could do if they somehow breached my password protected admin area.

The downside to this, is that it converted my line breaks to the characters:



When I output this content, I don't want that odd character sequence to display, I want it to display a visual line break. I can do this by swapping that code with the html tag <br> like so:
$content = str_ireplace('&#13;&#10;',"<br>n",$content);

Having done this, my text no longer all runs together in one solid unformatted block.

This is but one simple approach to handling characters safely, and it is not the best method. It's just a quick one-line modification that will serve its purpose for now. Watch for changes soon.

Category: Cms