Recently doing something with Zen Cart Mall system! See a bit of code!
function Notify ($eventID, $paramArray = Array ()) {
$observers = & Base::getstaticobserver ();
if (!is_null ($observers))
{
foreach ($observers as $key = = $obs) {
if ($obs [' eventID '] = = $eventID) {
$obs [' Obs ']->update ($this, $eventID, $paramArray);
}
}
}
}
Function & Getstaticobserver () {
return Base::getstaticproperty (' Observer ');
}
What does A & mean after each function in a class?
The meaning of Base::getstaticobserver () should be a way of representing a class! Is it a quote to add a & in front?
Why do I add a & when I define a method
Ask the great God to explain in detail!
Reply to discussion (solution)
& References
The first point is that a reference is obtained
The second place indicates that the method will return a reference
Finally, the $observers is base:: $observer Reference
Any modification to the $observers will affect base:: $observer
This in turn affects all uses of base:: $observer behavior
If base:: $observer is not used for scheduling, it is not advisable to use this notation.
Of course, even if base:: $observer applies To scheduling, it is not recommended. It's too vague.