Re: HELP ! ! ! something simple . . . :D
- From: "kostas1981" <kostas.perperidis@xxxxxx>
- Date: 30 Dec 2006 17:36:52 -0800
CorfuVBProgrammer schrieb:
This way it works but only into the constructor method.
I have try to use ot in other methods in the class and doesn't work ! !
! ? ? ?
Is any other way ? ? ?
Hello!
I'm a PHP newbie, but I've been busy writing much OO-Code over the last
years.
I had an idea solving this problem using the following scheme:
class A
{
public function methodA(){
//some useful code
}
class B
{
private A $instanceOfA; //but I am really not sure if this one's works
public __construct() {
$instanceOfA=new A();
}
public function methodB(){
$this->instanceOfA->methodA();
}
}
}
Anyway this is legal in terms of OO-Programming and also a well used
method for composing classes. I tried this out in PHP but it doesn't
seem to work. Obviously you'll have to create the instance within the
function/method you want to use it. Like:
class B
{
//....
public function methodB(){
$instanceOfA=new A();
$instanceOfA->methodA();
}
}
Well I ran a test with that and it worked. It's not that elegant but I
think it makes sense...
regards
Kostas
.
- Follow-Ups:
- Re: HELP ! ! ! something simple . . . :D
- From: Tim Van Wassenhove
- Re: HELP ! ! ! something simple . . . :D
- References:
- HELP ! ! ! something simple . . . :D
- From: CorfuVBProgrammer
- Re: HELP ! ! ! something simple . . . :D
- From: Kimmo Laine
- Re: HELP ! ! ! something simple . . . :D
- From: CorfuVBProgrammer
- Re: HELP ! ! ! something simple . . . :D
- From: CorfuVBProgrammer
- Re: HELP ! ! ! something simple . . . :D
- From: Yoursef
- Re: HELP ! ! ! something simple . . . :D
- From: CorfuVBProgrammer
- HELP ! ! ! something simple . . . :D
- Prev by Date: Re: Does PHP have an end-of-file problem.
- Next by Date: Re: I need some ideas on XML parsing.....
- Previous by thread: Re: HELP ! ! ! something simple . . . :D
- Next by thread: Re: HELP ! ! ! something simple . . . :D
- Index(es):