Page 1 of 1

Question re: Classes & Functions

Posted: Mon Aug 04, 2008 10:06 pm
by saturnprods
Hey everyone. I am learning to use classes.

I have run into a confusion -

Look at this breakdown:

***** PLEASE USE THE

Code: Select all

TAG *****[/color]

Code: Select all

class MyClass{
 
function functionA{
do this;
return that;
}
 
function functionB($variable){
 
$apple =  functionA($variable);
$apple .= '123';
return $apple;
 
}
 
}
----

This is a really simplified example to show the structure. My question is, when I call the Function A in Function B, do I need to do it some other way than the way a regular function is called? I am not sure about this.

Thanks.

Re: Question re: Classes & Functions

Posted: Mon Aug 04, 2008 10:45 pm
by Christopher

Code: Select all

class MyClass {
     protected $that = 0;
 
     function functionA() {
          $this->that = do_this();     // function outside the class
          return $this->that;
     }
 
     function functionB($variable) {
          $apple = $this->functionA($variable);   // method of class
          $apple .= '123';
          return $apple;
     }
}