im trying to make my first class in php from an exmple
http://www.php.net/manual/en/keyword.class.php
What i have:
file cart.php
<?php
class Cart
{
private $items; //items in our cart
public function Cart()
{
$this->add_item("03", 0);
}
public function add_item ($artnr, $num)
{
$this->items[$artnr] += $num;
echo "product added";
}
}
?>
file index.php
<html>
<head>
<?php
include_once('cart.php');
?>
<title>Test</title>
</head>
<body>
<?php
$test1 = new Cart();
?>
</body>
</html>
but it crashes on the line
this->add_item("03",0);
witht he error Undefined index: 03 in
I cant fix it, can some one help me?