Пример #1
0
<?php

class cat
{
    function makenoise()
    {
        return 'purr';
    }
    function speed()
    {
        return 'nippy';
    }
    //$this is a special variable that refers to the class's scope
    function output()
    {
        $noise = $this->makenoise();
        $speed = $this->speed();
        echo 'the cat says ' . $noise . ' and is very ' . $speed;
    }
}
$cat = new cat();
$cat->output();