You are here: OO PHP Referencing an instance of a class « PHP Programming Language « IT news, forums, messages
OO PHP Referencing an instance of a class

Posted by Areric on 04/11/06 18:32

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;
4:
5: function __construct()
6: {
7: $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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация