オブジェクト指向の PHP は初めてです。練習用のコードを書いたところですが、次のようなエラーが表示されます
Notice: Undefined variable: type in F:\xampp\htdocs\testing\scope.php on line 10
Notice: Undefined index: in F:\xampp\htdocs\testing\scope.php on line 10
$type
このエラーが発生しているためだと思います。誰か助けてくれませんか?前もって感謝します。
class Lookup {
public static $items = array();
public $x = '34';
public $y = '26';
public static function setItems($items, $x, $y) {
$items[$type] = array(
'x' => $this->x,
'y' => $this->y);
}
public static function getSum() {
$z = self::$items[$type]['x'] + self::$items[$type]['y'];
return $z;
}
}
echo Lookup::getSum();