0

通过电子邮件发送字符串后,我想将其保存到文件中。所以我这样做:

file_put_contents("coupon.txt", $email.  $RandomString  , FILE_APPEND | LOCK_EX);

这样它看起来像这样:

email@email.com12d45f8e9email2@email2.com1d2d5s4d51d

所以代码之间没有新行,也没有空格。当我托盘使用这种方式时:

file_put_contents("coupon.txt", $email. .  $RandomString .PHP_EOL.  , FILE_APPEND | LOCK_EX);

它只是不会保存任何东西,更多的是错误的邮件发送。

塔尔。

4

2 回答 2

1

在要写入的字符串中使用 \t 和 \n。

file_put_contents("coupon.txt", $email."\t". $RandomString . "\n" , FILE_APPEND | LOCK_EX);

于 2015-08-27T09:41:07.707 回答
0

您需要附加“\n”,试试这个:

file_put_contents("coupon.txt", $email . "  " . $RandomString . "\n"  , FILE_APPEND | LOCK_EX);
于 2015-08-27T09:42:23.957 回答