Jump to content

Recommended Posts

Hi Guys,

 

say i have $_POST data to deal with to add spaces and line breaks:

 

$_POST['message'];

 

i usually do:

 

  $message      = nl2br($message);

  $message      = addslashes($_POST['message']);

 

Is there a certain way to apply both functions on the same line like:

 

  $message      = nl2br(addslashes($message));

 

or

 

  $message      = addslashes(nl2br($message));

 

or doesn't it matter in what order?

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/139610-applying-functions-question/
Share on other sites

No, but I would suggest against using addslashes as it is in the process of being depreciated.

 

If you are filtering this for db entry use mysql_real_escape_string instead and no it does not matter which order you use. And I would suggest storing the data in it's raw format and use nl2br before you display the data to the user.

Well I would not addslashes then, there is no need to. If you do it will look like this:

 

Hello I can\'t decide...

 

Etc. So remove that part, and if it is not an html email, the nl2br will not do much good. I think the basic text will display like it should with the line breaks. If it is html, then yea use the nl2br.

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.