Skip to content

Instantly share code, notes, and snippets.

@katsube
Created December 3, 2022 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsube/96005b4531737e1a1e263988bbc559c8 to your computer and use it in GitHub Desktop.
Save katsube/96005b4531737e1a1e263988bbc559c8 to your computer and use it in GitHub Desktop.
<?php
$tama = new Cat('たま', 'にゃー');
$tama->mynameis(); // "私の名前はたまです。"
$tama->say('こんにちは'); // "こんにちはにゃー"
class Animal{
protected $name;
function __construct($name){
$this->name = $name;
}
function mynameis(){
printf("私の名前は%sです。\n", $this->name);
}
}
class Cat extends Animal{
// ★ここを埋める★
function __construct($name, $tail){
parent::__construct($name);
// ★ここを埋める★
}
// ここにメソッドを追加
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment