<?php
class Point {
protected $x;
protected $y;
public function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}
public function toArray() {
return (array)$this;
}
}
$p = new Point(4, 5);
var_dump($p->toArray()); // ["*x" => 4, "*y" => 5]
To embed this program on your website, copy the following code and paste it into your website's HTML: