コード例 #1
0
ファイル: multipass.php プロジェクト: jperezh/paradigms2015
        $this->name = $name;
    }
    public function setFather(Person $father)
    {
        if ($father == "god") {
            echo "YISUS CRIST";
            $this->father = $father;
        } else {
            $this->father = $father;
        }
    }
}
// Instantiate the objects
$parent = new Man("god");
$son = new Man("Yisus");
$son->setFather($parent);
echo "The father of " . $son->name . " is: " . $parent->name;
$convertWine = function ($personName) {
    if ($personName == "Yisus") {
        return "can";
    } else {
        return "can not";
    }
};
echo ", and he " . $convertWine("cas") . " convert water into wine\n";
// Some closures
$parentName = $parent->name;
$moonwalk = function ($name) use($parentName) {
    if ($name == "Yisus" && $parentName == "god") {
        return "He can also walk in the water!\n";
    }