$this->set('title', 'Title Name'); not working in CakePHP 3.x
问题 Basically in default.ctp I have this for my title: <title> <?= $this->fetch('title') ?> </title> And inside of the controller I have this line: $this->set('title', 'Test-Title'); But it does nothing, it still displays controllers name(Jobs, controllers full name os JobsController.ctp) But if I put this inside of my view file: $this->assign('title', 'Test-Title'); It changes the title. So what is wrong with $this->set('title', $title) ? 回答1: You can just set() the variable in your controller: