Структуры (записи)

<?php

//In PHP there are no structures
class Point {
    public $x, $y;

    function toText(): string {
        return "x = $this->x; y = $this->y";
    }

    function move(int $right, int $down) {
        $this->x += $right;
        $this->y += $down;
    }
}

$p1 = new Point();
$p1->x = 1;
$p1->y = 2;
$str1 = $p1->toText();
//str1 is "x = 1; y = 2"
echo $str1, "\n";

$p1->move(5-1);
$str2 = $p1->toText();
//str2 is "x = 6; y = 1"
echo $str2, "\n";