Jump to content

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/85854-what-does-this-do/
Share on other sites

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 ?

Link to comment
https://forums.phpfreaks.com/topic/85854-what-does-this-do/#findComment-438224
Share on other sites

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,

Link to comment
https://forums.phpfreaks.com/topic/85854-what-does-this-do/#findComment-438309
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.