Johhny P
Johhny P

Reputation: 161

How to pass simple data from controller to view in cakePHP

I get an int value to the controller and I would like to send it to the according view, but i am either passing or accesing it wrong. Here is what I am trying to do:

Controller:

function send($int = NULL) {
    $this->set('integer', $int);

}

View:

echo $integer['int']

Your help is much appreciated!

Upvotes: 7

Views: 15256

Answers (1)

cowls
cowls

Reputation: 24334

Change

echo $integer['int']

To:

echo $integer;

The first parameter in $this->set is used as the variable name in your view, the second parameter is the value assigned to that variable.

Upvotes: 13

Related Questions