graham23s Posted January 6, 2009 Share Posted January 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/139610-applying-functions-question/ Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/139610-applying-functions-question/#findComment-730403 Share on other sites More sharing options...
graham23s Posted January 6, 2009 Author Share Posted January 6, 2009 Hi Premiso, it's really for a contact form, i will be e-mailed a copy of the message, does that make a difference? thanks mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/139610-applying-functions-question/#findComment-730404 Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/139610-applying-functions-question/#findComment-730406 Share on other sites More sharing options...
graham23s Posted January 6, 2009 Author Share Posted January 6, 2009 ah got ya. thanks for clearing that up mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/139610-applying-functions-question/#findComment-730409 Share on other sites More sharing options...
Maq Posted January 6, 2009 Share Posted January 6, 2009 If you call, nl2br(addslashes($message)); It will perform the addslashes then nl2br. In some cases it can make a difference. Quote Link to comment https://forums.phpfreaks.com/topic/139610-applying-functions-question/#findComment-730524 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.