Page 1 of 1

Use one function to call another

Posted: Thu Apr 20, 2006 4:16 pm
by Tehquickness
I have a quick question, if I have a function can i use it to call other functions outside of itself?
Example

Code: Select all

class DailyActivities{
     var $something;
     var $somethingelse;

   function Day($whichday){
      $this->something = gotoWork();
      $this->somethingelse = gotoSchool();

}

   function gotowork(){
      return $var;
}

   function gotoSchool(){
      return $anothervar;
}
}

this way when the function Day() is called, it will activate and execute the other functions. Is that possible or does the I want to be called have to be inside the function I am already using?

Posted: Thu Apr 20, 2006 4:28 pm
by feyd
Functions can call other functions. Methods can call other methods and functions. The code you posted would be a method to method call. When calling another method of the same class $this-> should be used if you want to refer to the current (active) instance of the class (i.e. object)

Posted: Thu Apr 20, 2006 4:30 pm
by Tehquickness
Awesome. That is just what I needed. Thanks for the help.