For some reason, strings in PHP can cause this behaviour, since escaping characters can only happen inside double quotes.
If you have any string, you can overcome this PHP limitation by just using this line of code:
$msg = str_replace('\n', "\n", $msg);
*where msg is your string.