Jump to content

Applying functions question


graham23s

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.

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.