> Any insight appreciated. In a best case if someone can add in the required
> '&'s to the following code that would be great.
<?php
echo '<pre>' ;
error_reporting ( E_ALL ) ;
class Foo {
var $bars = array() ;
function AddBar($id,$text)
{
$obj = new Bar ( $text ) ;
$this->SetBar ( $id , $obj ) ;
}
function SetBar($id,&$bar)
{
$this->bars[$id] = $bar ;
}
function GetBar($id) {
return $this->bars[$id];
}
function SetBarMarklarSyntaxA ($id,$value)
{
/*
This syntax works...
*/
$this->bars[$id]->SetMarklar($value) ;
}
function SetBarMarklarSyntaxB ($id,$value)
{
$reference_to_bar = &$this->GetBar($id) ;
$reference_to_bar->SetMarklar($value) ;
}
}
class Bar {
var $marklar = '' ;
function Bar($marklar) {
$this->SetMarklar($marklar) ;
}
function SetMarklar($value)
{
$this->marklar = $value ;
}
}
//-----------
$foo = new Foo ;
$foo->AddBar('one','un') ;
$foo->AddBar('two','duex') ;
print_r($foo) ;
//Works
$foo->SetBarMarklarSyntaxB('one','eins') ;
$foo->SetBarMarklarSyntaxB('two','zwei') ;
print_r($foo) ;
echo '</pre>' ;
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php