0

I have come accross a function:

public function plgVmPrepareCartProduct(&$product, &$customfield,$selected,&$modificatorSum){

what does the & in front of the variable mean?

  • It means 'By Reference'. It means if you modify $product inside the function, then it will affect $product (or the original variable) outside the function too – Farkie Jul 06 '16 at 08:31
  • $customfield it contains value, &$customfield contains address of $customfield .for example: $a=1; $b=& $a; echo $a ;// outputs 1 echo $b ;// also outputs 1, because it store address of $a it might be a garbage value if you change value of $a automatically it will affect to $b also – Naisa purushotham Jul 06 '16 at 08:35

0 Answers0