thefollower Posted January 13, 2008 Share Posted January 13, 2008 Some one showed me a bit of script then failed to tell me what it does lol . So was hoping some one could explain what this does: $response is from a $_POST and relates to a message.. $Response = str_replace(array("\r\n", "\r", "\n"), ' ', $Response); Hope you can explain it Quote Link to comment https://forums.phpfreaks.com/topic/85854-what-does-this-do/ Share on other sites More sharing options...
tinker Posted January 13, 2008 Share Posted January 13, 2008 http://uk3.php.net/manual/en/function.str-replace.php, always use the manual as first stop when learning, it's unbelievably informative (look for the search bar, then the 'See Also' section before the comments, then the left menu) Quote Link to comment https://forums.phpfreaks.com/topic/85854-what-does-this-do/#findComment-438217 Share on other sites More sharing options...
thefollower Posted January 13, 2008 Author Share Posted January 13, 2008 I had already read that and it says : // Processes \r\n's first so they aren't converted twice. And then well.. why would it convert those 2 letters twice anyway i dont understand why it would need to convert anything ? Is there a dangerous security flaw with users typing \r\n's into a string which is why he replaces them ? Quote Link to comment https://forums.phpfreaks.com/topic/85854-what-does-this-do/#findComment-438224 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 No, they are just line feeds. Quote Link to comment https://forums.phpfreaks.com/topic/85854-what-does-this-do/#findComment-438230 Share on other sites More sharing options...
Barand Posted January 13, 2008 Share Posted January 13, 2008 On a Mac system a newline is "\r" (carriage return) On a Nix system a newline is "\n" (linefeed) Windows however never evolved from the days of the old mechanical teletype which required the carriage to be returned back to the left hand edge and the paper fed forward, so it requires "\r\n" (carriage_return + linefeed) So the code replaces all flavours with a single space, Quote Link to comment https://forums.phpfreaks.com/topic/85854-what-does-this-do/#findComment-438309 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.