我使用了忘记密码包。设置文件是\ config \ mail.php。事情很好。
然后我将设置更改为.env,字符错误,乱码。 实际上,4个汉字,2个是正常的,2个是乱码。
.ENV
FROM_NAME=通天教主
\设置\ mail.php
'from' => ['address' => env('FROM_ADDRESS'), 'name' => '通天教主'], //normal
'from' => ['address' => env('FROM_ADDRESS'), 'name' => env('FROM_NAME')], //garbled
'from' => ['address' => env('FROM_ADDRESS'), 'name' => mb_convert_encoding(env('FROM_NAME'), "UTF-8", "Big5")], //garbled
'from' => ['address' => env('FROM_ADDRESS'), 'name' => mb_convert_encoding(env('FROM_NAME'), "UTF-8", "auto")], //garbled
我用notepad ++检查过,这两个文件是没有BOM的utf8。 Apache服务器:VirtualHost:addDefaultCharset UTF-8 PHP php.ini:default_charset =“UTF-8”
然后我试着回应一下\ config \ mail.php的大声,检测它的编码
\设置\ mail.php
<?php
$str = env('FROM_NAME') . "\r\n";
echo mb_detect_encoding(env('FROM_NAME'));
exit;
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
... ...
... ...
这是utf8,但也是乱码。
这可能是因为Windows + xampp吗?任何决议?