Beispiel #1
0
    public $iq = 100;
    public function say()
    {
        $arr = array('早上好', '晚上好', 'shit');
        if ($this->iq >= 100) {
            echo $arr[0];
        } else {
            $rad = rand(0, 2);
            echo $arr[$rad];
        }
    }
}
class car
{
    public function hit($m)
    {
        $ra = rand(50, 150);
        $m->iq = $ra;
    }
}
$m = new man();
$c = new car();
echo $m->say();
echo "<br>";
$c->hit($m);
echo $m->iq;
echo "<br>";
echo $m->say();
echo "<br>";
echo $m->say();
echo "<br>";