Note Submitter: dishmael at windwardcg dot com
----
I'm still new to PHP so please bear with me. I have two
simple classes:
class Foo {
private $Bars; // an array of Bar objects
function Foo() {
$this->Bars = array();
}
function addBar( &$bar ) {
array_push( $this->Bars, $bar );
}
function toString() {
while ( $bar = each( $this->Bars) ) {
echo $bar->toString() // this generates an error
}
}
}
class Bar {
function toString() {
return "Test";
}
}
$foo = new Foo();
$foo->addBar( new Bar() );
$foo->toString();
Which generates the following error:
Fatal error: Call to a member function toString() on a
non-object in test.php
Can any of you PHP gurus point me to what I'm doing wrong?
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|