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!
By this set() function, we can pass a value to the view template, and we can add any variable from the controller by use of set(). This set variables will be available in both the view and the layout of your action renders.
Many applications have small blocks of presentation code that need to be repeated from page to page, sometimes in different places in the layout. CakePHP can help you repeat parts of your website that need to be reused. These reusable parts are called Elements.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With