Code: Select all
<?php
class BlockRenderer {
var $blocks = array();
function addBlock(& $block) {
$this->blocks[] = & $block;
}
function render() {
foreach ( $this->blocks as $key => $block ) {
// foreach (in PHP4) makes copies not references to variables,
// hence the $key is used, not the $block
$this->blocks[$key]->draw();
}
}
}
?>Now, why did the auther use a & (reference) by addBlock function?
Why is this useful? Is it necessary? Can someone explain me this?
(please don't give me the link of references in php manual..)