Exemple #1
0
<?php

$kid = new Kid();
$kid->setName('ドラミ');
$kid->setSex('girl');
echo $kid->showName();
$kid2 = new Kid();
$kid2->setName('ジャイアン');
$kid2->setSex('boy');
echo $kid2->showName();
class Kid
{
    private $name;
    private $sex;
    private $age;
    function __construct()
    {
        $this->name = 'Seed';
        $this->sex = 'boy';
    }
    public function setName($namae)
    {
        $this->name = $namae;
    }
    public function getName()
    {
        return $this->name;
    }
    public function setSex($gender)
    {
        return $this->sex = $gender;