<?php
class fish {
public function eating($food) {
echo "Fish is eating " . $food;
}
public function swim() {
echo "Fish is swimming!";
}
}
class People {
private $fish;
private $food;
public function __construct(fish $fish, $food) {
$this->fish = $fish;
$this->food = $food;
}
public function fishing() {
$this->fish->eating($this->food);
}
public function getFish() {
echo "put up the fish!";
}
}
$jiyu = new fish();
$jiyu->swim();
echo '<hr/>';
$p = new People($jiyu, '蚯蚓');
$p->fishing();
echo "<hr/>";
$p->getFish();
2024 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123