msgid "msg" msgstr "CakePHP Internationalization example."
<?php echo __('msg'); ?>
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US')
use Cake\I18n\I18n;
I18n::locale('de_DE');
<?php use Cake\Http\Middleware\CsrfProtectionMiddleware; use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/', function (RouteBuilder $builder) { $builder->registerMiddleware('csrf', new CsrfProtectionMiddleware([ 'httpOnly' => true, ])); $builder->applyMiddleware('csrf'); //$builder->connect('/pages', ['controller'=>'Pages','action'=>'display', 'home']); $builder->connect('locale', ['controller'=>'Localizations','action'=>'index']); $builder->fallbacks(); });
<?php namespace App\Controller; use App\Controller\AppController; use Cake\I18n\I18n; class LocalizationsController extends AppController { public function index() { if($this->request->is('post')) { $locale = $this->request->getData('locale'); I18n::setLocale($locale); } } } ?>
msgid "msg" msgstr "CakePHP Internationalization example."
msgid "msg" msgstr "Exemple CakePHP internationalisation."
msgid "msg" msgstr "CakePHP Internationalisierung Beispiel."
<?php echo $this->Form->create(NULL,array('url'=>'/locale')); echo $this->Form->radio("locale", [ ['value'=>'en_US','text'=>'English'], ['value'=>'de_DE','text'=>'German'], ['value'=>'fr_FR','text'=>'French'], ] ); echo $this->Form->button('Change Language'); echo $this->Form->end(); ?> <?php echo __('msg'); ?>
use Cake\Mailer\Email;
语法 |
From(string|array|null
$email null, string|null
$name null )
|
参数 | 带电子邮件的字符串 姓名 |
返回 |
数组|$this
|
描述 |
它指定来自哪个电子邮件地址;电子邮件将被发送
|
语法 |
To(string|array|null
$emailnull, string|null
$namenull)
|
参数 | 带电子邮件的字符串 姓名 |
返回 |
数组|$this
|
描述 |
它指定电子邮件将发送给谁
|
语法 |
发送(string|array|null
$contentnull)
|
参数 | 带有消息的字符串或带有消息的数组。 |
退货 | 数组 |
描述 |
使用指定的内容、模板和布局发送电子邮件
|
语法 |
Subject(string|null
$subjectnull)
|
参数 | 主题字符串 |
返回 |
数组|$this
|
说明 |
获取/设置主题
|
语法 |
Attachments(string|array|null $attachmentsnull)
|
参数 | 带有文件名的字符串或带有文件名的数组 |
退货 |
数组|$this
|
说明 |
在电子邮件中添加附件
|
语法 |
Bcc(string|array|null
$emailnull, string|null
$namenull)
|
参数 | 带电子邮件的字符串 姓名 |
退货 |
数组|$this
|
说明 |
密件抄送
|
语法 |
cc( string|array|null
$emailnull , string|null
$namenull )
|
参数 | 带电子邮件的字符串 姓名 |
退货 |
数组|$this
|
说明 |
抄送
|
<?php use Cake\Http\Middleware\CsrfProtectionMiddleware; use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/', function (RouteBuilder $builder) { $builder->registerMiddleware('csrf', new CsrfProtectionMiddleware([ 'httpOnly' => true, ])); $builder->applyMiddleware('csrf'); //$builder->connect('/pages',['controller'=>'Pages','action'=>'display', 'home']); $builder->connect('/email',['controller'=>'Emails','action'=>'index']); $builder->fallbacks(); });
<?php namespace App\Controller; use App\Controller\AppController; use Cake\Mailer\Email; class EmailsController extends AppController{ public function index(){ $email = new Email('default'); $email->to('abc@gmail.com') ->subject('About') ->send('My message'); } } ?>
Email Sent.