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
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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.