Posted by David Haynes on 04/11/06 19:27
Areric wrote:
> Ok all im havign some issues with a class im writing was hoping you all
> could help. I dont have access to the actual code here but ill write
> out an example of what im trying to do and maybe you all could provide
> some pointers.
>
> 1: class Foo
> 2: {
> 3: $mInstanceBar;
private $mInstanceBar;
> 4:
> 5: function __construct()
> 6: {
> 7: $this->mInstanceBar = & new Bar();
$this->mInstancebar = new Bar();
> 8: }
> 9:
> 10: function callBarHelloWorld()
> 11: {
> 12: $this->mInstanceBar->HelloWorld();
> 13: }
> 14: }
> 15:
> 16: class Bar
> 17: {
> 18: function HelloWorld()
> 19: {
> 20: echo "Hello World!";
> 21: }
> 22: }
> 23: $foo = new Foo();
> 24: $foo->callBarHelloWorld();
>
> Ok line 12 returns an error saying something to the effect that im
> calling a function on something that is not an object.
>
> My impression was that on line 7 i am instantiating the object as a
> reference which should still be available when called on line 12.
>
> So any ideas?
>
[Back to original message]
|