cakephp 3.0 中 set 和 serialized 之间的核心区别?

core difference between set and serialized in cakephp 3.0?

    $player = $this->Players->get($id, [
        'contain' => []
    ]);
    $this->set('player', $player);
    $this->set('_serialize', ['player']);

如果我将删除 $this->set('_serialize', ['player']) ,我认为没有任何区别。

        <h6 class="subheader"><?= __('First Name') ?></h6>
        <p><?= h($player->first_name) ?></p>
        <h6 class="subheader"><?= __('Last Name') ?></h6>
        <p><?= h($player->last_name) ?></p>
        <h6 class="subheader"><?= __('Email') ?></h6>
        <p><?= h($player->email) ?></p>
        <h6 class="subheader"><?= __('Password') ?></h6>
        <p><?= h($player->password) ?></p>
        <h6 class="subheader"><?= __('Birthdate') ?></h6>
        <p><?= h($player->birthdate) ?></p>
        <h6 class="subheader"><?= __('Mailning Address') ?></h6>
        <p><?= h($player->mailning_address) ?></p>
        <h6 class="subheader"><?= __('City') ?></h6>
        <p><?= h($player->city) ?></p>
        <h6 class="subheader"><?= __('State') ?></h6>
        <p><?= h($player->state) ?></p>
        <h6 class="subheader"><?= __('Country') ?></h6>

The _serialize key is a special view variable that indicates which other view variable(s) should be serialized when using a data view. This lets you skip defining template files for your controller actions if you don’t need to do any custom formatting before your data is converted into json/xml. http://book.cakephp.org/3.0/en/views/json-and-xml-views.html#using-data-views-with-the-serialize-key

对于 xml 和 json 视图来说这是一个不错的功能,但如果您使用自己的视图模板就几乎没用了。