出于某种原因,将 laravel 控制器中的 $.post 变量与字符串进行比较不起作用


Comparing $.post variable in laravel controller to a string for some reason doesnt work

这是我的jquery,将数据发送到我的laravel控制器。

$.post(url, { ChatText : ChatText }, function(data) {});

一切都很完美。我可以通过Input::get('ChatText')获得它。

但这是我不明白的事情。当我想比较Input::get('ChatText')时,例如这样:

$text = 'test';
$input = Input::get('ChatText');
if($text == $input){
}    

由于某种原因,这不起作用。它仅适用于数字。现在在谷歌搜索之后,我发现了一些与编码有关的帖子。但是我检查了一下,它都是 UTF-8。

Andeersg是正确的。

preg_replace( "/'r|'n/", "", $input);让它工作