0

$cart = &$_SESSION['journal_items']; anybody know when do we use the & symbol like that?

Phiter
  • 14,570
  • 14
  • 50
  • 84

1 Answers1

0

Basically it means that $cart won't get the value stored in $_SESSION['journal_items'], but it's reference. Whenever you call $cart, you'll be calling the current value of $_SESSION['journal_items'], even if it has been changed after this declaration.

Example:

$_SESSION['journal_items'] = "test";
$cart = &$_SESSION['journal_items'];
//$cart's current value is "test"

$_SESSION['journal_items'] = "test2";
//$cart's current value is "test2"

See this answer and this reference book.

Community
  • 1
  • 1
Phiter
  • 14,570
  • 14
  • 50
  • 84