PHP: classe et héritage

Author:

 héritage
Download

<?php

class Panier {
    var $produit= array(5);

    function ajouter_produit ($artnr, $num)
    {
        $this->produit[$artnr] += $num;
    }

    function supprimer_produit ($artnr, $num)
    {
        if ($this->produit[$artnr] > $num) {
            $this->produit[$artnr] -= $num;
            return true;
        } else {
            return false;
        }
    }
}
class Panier_Mixte extends Panier
{
    var $proprietaire;
    function modifier_proprietaire ($nom)
    {
        $this->proprietaire = $nom;
    }
}

$nPanier = new Panier_Mixte;
$nPanier->modifier_proprietaire ("Jhon Deer");
print $nPanier->proprietaire;
$nPanier->ajouter_produit ("0", 1);
?>

Leave a Reply

Your email address will not be published. Required fields are marked *


two + 1 =