简体   繁体   English

蛋糕PHP换行符

[英]Cake php newline character

i am using the cakephp paranoid function but i want it to not strip new line character . 我正在使用cakephp 偏执函数,但我希望它不剥离换行符 I tried passing \\n in allowed chars but it failed 我尝试在允许的字符中传递\\ n ,但失败

You have to make sure you using the correct quotes: 您必须确保使用正确的引号:

echo Sanitize::paranoid($badString,array("\r\n","\n"));

Always use double quotes if your sending in escape chars, and if your stripping both returns and newlines make sure that "\\r\\n" comes before, as im sure the function will sanitize int he order of chars passed in. 如果您发送的是转义字符,请始终使用双引号,并且如果要同时去除返回和换行符,请确保前面加上"\\r\\n" ,因为我确信该函数会清除传入的字符顺序。

What syntax are you using? 您使用什么语法? Make sure that $allowedChars is an array and that you used double-quotes for the newline (single-quotes do not parse escapes like newline): 确保$allowedChars是一个数组,并且对换行符使用双引号(单引号不会像换行符一样解析转义符):

Sanitize::paranoid($badString, array("\n"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM