コード例 #1
0
ファイル: objects.php プロジェクト: VeraKH/PHP-repo
    }
}
$book = new book();
$book->title = "Lord of the Rings. ";
$book->author = "JR Tolkien";
$book->yearOfPublishing = "1928";
$book->format;
// ="Hardcover";
echo "Title: " . $book->title . $book->summary();
//Inheritance
class Animal
{
    var $color;
    var $location = "North America. ";
    function getColor()
    {
        return $this->color;
    }
    function getLocation()
    {
        return $this->location;
    }
}
class Fish extends Animal
{
}
$jellyfish = new Fish();
$jellyfish->location = "Pacific Ocean. ";
$jellyfish->color = "blue. ";
echo $jellyfish->getColor() . $jellyfish->getLocation();