views:

401

answers:

2

I used Sanitize::clean in cakePHP to sanitize user input and in result I got "\r" character.

  1. What does this character mean ("\r") ?
  2. Is there a function that does the reverse of Sanitize::clean, so I can use before outputting the data.
+1  A: 

"\r" is the Carriage Return character (when printing to the console, it causes output to start on the next line but does not affect display of web pages).

Eric J.
I believe that it is the Windows return character, and while necessary for some operations (writing to a notepad doc I think requires it), "\n" will also work in the console, and for many (most?) uses.
Nona Urbiz
+1  A: 

You can get rid of this character (and others) by calling trim($userInput); or this way using Sanitize::clean :

$opts = array('carriage'=>true);
$cleaned = Sanitize::clean($userInput,$opts);
inkedmn