Category: Views

Q: compact($var) in CakePHP

When you are passing a variable from controller to view, you use the set function, but..

Compare

$this->set('var', $var);

to the following

$this->set(compact('var'));

Which one is better?  

SOLVED
1 Answers
user
Kake

3

Accepted by Kake

Both methods do not have major differences.

Ksmacky
Ksmacky

30

Created: 8 Oct '16

Last Reply: 9 Oct '16

Replies: 1

Views: 418

Votes: 0

Welcome to Aero Coding!

Aero Coding is a CakePHP-focused Q&A community for professional and enthusiast cake bakers. It's built and run by you as part of the community.


Join Now Tour

Download Cakephp

Start baking your own CakePHP application!


Cakephp All Versions