$cart = &$_SESSION['journal_items']; anybody know when do we use the & symbol like that?
Asked
Active
Viewed 43 times
0
Phiter
- 14,570
- 14
- 50
- 84
Aldi Fajrin
- 3
- 3
1 Answers
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.
-
Thanks for the help @phiter, really helpful – Aldi Fajrin Sep 03 '16 at 02:42