This forum is now read-only. Please use our new forums at

86 points
Submitted by
almost 3 years ago

Want your dog to bark() while greet()ing?

It is not really a question actually. I tried to find out a way of calling a method from another method and found it! Here is how to do it:
class Dog{
public $numLegs = 4;
public $name;
public function __construct($name){
$this->name = $name;
public function bark(){
return "woof!";
public function greet(){
return "hello,".$this->bark()." my name is ".$this->name." ".$this->bark();

You chould simply put "woof" instead of calling bark(), but it might be useful for your other projects ^.^