Jump to content

[SOLVED] htmlspecialcharacters


Northern Flame

Recommended Posts

I got a script from the PHP Freaks Quick Codes and I was customizing it and on one of the files they included these to things:

htmlspecialcharacters(...);

and

n12br(htmlspecialcharacters(...));

(of course without the "..." i just didnt want to retype everything)

 

what is the difference between the first and second?

Link to comment
https://forums.phpfreaks.com/topic/59742-solved-htmlspecialcharacters/
Share on other sites

Well, first of all there is no "htmlspecialcharacters(...);" It's htmlspecialchars :P

 

htmlspecialchars() Converts any character that has specific significance in HTML to a text safe equivalent... I haven't really tested it, but it looks like it's similar to htmlentities, so I'd assume it does stuff like turns < into <

 

nl2br() adds a line break (< br>) before each newline (\n) in a string. This is particularly useful for things such as textareas, where a user may enter a bunch of text using newlines to space everything out... then php represents those newlines a "\n", which in html... means nothing. So in order to display their text in html, you have to add line breaks before each newline

 

So draw your own conclusions... the two functions are primarily used for processing information from forms, just use whatever you need to.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.