Пример простого класса на php с конструктором


<?
class Example
{
    private $var1;
    private $var2;
    private $var3;

    public function __construct($var1, $var2, $var3)
    {
        $this->var1 = $var1;
        $this->var2 = $var2;
        $this->var3 = $var3;

    }

    public function Example_function_sum()
        {
            $sum = $this->var1 + $this->var2 + $this->var3;
            return $sum;
        }

}

$a = (new Example(1, 2, 3))->Example_function_sum();

echo $a;

?>