[I'm learning PHP now and using this Polish site: ][1]http://phpkurs.pl/ponowne-uzycie-kodu/
I'm stuck on this example:
<?php
class Koszyk
{
var $artykuly;
function dodaj($numer, $ilosc)
{
$this->artykuly["$numer"] += $ilosc;
}
function usun($numer, $ilosc)
{
if($this->artykuly["$numer"]>$ilosc)
$this->artykuly["$numer"]-=$ilosc;
else
$this->artykuly["$numer"]=0;
}
function wyswietl()
{
while(list($k, $v) = each($this->artykuly))
if($v>0)
echo "Artykul nr $k - $v sztuk<br>";
}
}
$koszyk = new Koszyk;
$koszyk->dodaj('20', 2);
$koszyk->dodaj('12', 4);
$koszyk->dodaj('20', 5);
$koszyk->usun('12', 4);
$koszyk->wyswietl();
?>
I know that var is not needed because it was used in PHP 4, but the code is not working and I'm getting errors. I can't figure out what is the problem. I think it's something simple but it is example so it should be working.