Created
December 3, 2022 16:03
-
-
Save katsube/96005b4531737e1a1e263988bbc559c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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