> pf@xxxxxxxxxxxxxxxxxxxxxxxx wrote: >> Hello. >> Please consider this: >> >> class A { >> >> function A(&$Cont){ > > you obviously didn't RTFM about php5's new features, migration issues > etc..... > > why do I say that? well it because you are using a '&' > each time you assign an object. thats not how its done in > php5 - hint: php5 has real objects, an object is always a > reference, you can assign an object to a hunderd vars and they will > all point to the same object - if you need to copy > an object use 'clone'. Cool feature, but I've not tried php5 yet, I'm been lazy the last couple of months. So the example is for php4 I thought it was obvious because of the constructor name. > >> $this->Container= &$Cont; >> } >> >> function A_1(){ >> $this->Container->objB->B_1("somehing"); >> } >> } >> class B { >> >> function B(&$Cont){ >> $this->Container= &$Cont; >> } >> >> function B_1(){ >> //anything >> } >> } >> >> class Container{ >> >> function Container(){ >> $this->objA=new &A($this); > > ^--- I'm surprised that this even parses. > >> $this->objB=new &B($this); >> } >> } >> >> $MyOBJ=new Container(); >> >> >> The problem is that "sometimes" member functions and variables can be >> reached this way, but sometimes not (mainly variables or file pointers) >> depending WHEN you create the object and when (for example) you create a >> file pointer inside some class. >> >> What I want to do is to be able to use any function of any class from >> any >> function of any class. > > try the function pattern - basically you just use functions and then you > don't > have to worry about class scope etc; the ability for everyone of your > functions to > call everyone of your functions is built into php. thanks for the advice, but I like to program using classes, besides the class scope helps with names conflicts. > > i.e. it _sounds_ like a bad idea. the idea behind objects is making things > more > managable not creating hyper-spaghetti. > you're right, but if you dont want to keep extending classes or you have a project where classes heavily interact with each other, you will end up accesing other objects function/vars many of wich where created after you asigned the container reference to the calling object. Thanks a lot for your answer. >> >> Any ideas are welcome. >> >> Thanks a lot in advance! >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php