换行\ n很奇怪,输出不起作用,PHP 7.1

时间:2018-08-04 19:42:39

标签: php html5 mysqli sms

我正在尝试发送短信并获得不同的结果。我阅读了所有其他可能性,但仍未找到解决方案。

我得到2个不同的结果。一个来自变量字符串,另一个来自数据库。

第一个例外。

conda update setuptools

预期输出:

$body2 = "Bombshell Image with \nSpace in name";
print_r($body2);

第二个来自数据库:

Output: Bombshell Image with Space in name

输出不一样:

$body = $res->message;
//$res->message = 
Bombshell Image with \nSpace in name
print($body);

我还尝试将标题更改为文本:

Output: Bombshell Image with \nSpace in name

当我运行gettype()时,它们都以字符串形式返回。 MySQL数据库中的字段设置为text和utf8_unicode_ci。 我没主意了!

有人对此有想法吗?

1 个答案:

答案 0 :(得分:0)

让它正常工作...添加了此代码

    $body =  str_replace('\n', "\n", $body);

也许其他人可以解释为什么现在可行。

相关问题