:::

26. Method

<?php
  class Dog {
    public $numLegs = 4;
    public $name;
    public function __construct($name){
        $this->name = $name;
          }
    public function bark() {
  return "Woof!";
  }

  public function greet() {
  return $this->name;
  }

  }
  $dog1 = new Dog("Barker");
  $dog2 = new Dog("Amigo");
  echo $dog1->bark();
  echo $dog2->greet();
        
        ?><!-- Your code here -->
      </p>


:::

語系選擇