0

How do I set the index of Zend Session with a variable name? For instance, is there a way of doing this?

$model = new Zend_Session_Namespace('models');
$model::set($index, $value);

I want the index ($model->index) to be a variable. Is this possible?

2 Answers2

1

No problem:

$model->$index = $value
Erlock
  • 1,968
  • 10
  • 11
0
$model = new Zend_Session_Namespace('models');
$model->{$index} = $value;

I think this is better.

Thanh Nguyen
  • 5,174
  • 11
  • 43
  • 74
  • Curly braces are only required when you use variables or expressions that return invalid property name. If you have control over these names, it's optional. – Erlock Nov 28 '13 at 16:23