Yükleniyor...

PHP Class Turetme Örneği

Etiketler: PHP Class Class
PHP Class Turetme Örneği
php-class-turetme-ornegi
<?php
/**
 * class turetme ornegi
 * ayhan baris
 */


/**
 * canlilara ait genel ozellikler ve olaylar
 */
class canli {
    public $kutle;

    function nefes_al(){
        echo "nefes al<br>n";
    }

    function nefes_ver(){
        echo "nefes ver<br>n";
    }
}

/**
 * insanlara ait genel ozellikler ve olaylar
 */
class insan extends canli {
   
    public $goz_rengi;
    public $sac_rengi;

    function uyu(){
        echo "uyuyor...<br>n";
    }

    function calis(){
        echo "calisiyor...<br>n";
    }

}

/**
 * bebeklere ait genel ozellikler ve olaylar
 *
 */
class bebek extends insan{
   
    function agliyor_mu(){
        echo "hayir su anda aglamiyor...<br>n";   
    }
   
    function yurumeye_basladi_mi(){
        echo "evet<br>n";
    }
   
}

/**
 * evcil hayvan genel ozellikler ve olaylar
 */
class evcil_hayvan extends canli{
   
    public $cinsiyet;
    public $tip; // kara , su
   
    function acikti_mi() {
        echo "tok...<br>n";   
    }
   
    function huysuz_mu(){
        echo "evet...<br>n";
    }
   
}

# * # * # * # * # * # * # * # * # * # * # * # * # * # * 

$class_insan = new insan;
$class_insan->nefes_al();
$class_insan->nefes_ver();

echo str_repeat("-",20);
echo "<br>n";

$class_bebek = new bebek;
$class_bebek->nefes_al();
$class_bebek->nefes_ver();
$class_bebek->uyu();
$class_bebek->yurumeye_basladi_mi();

echo str_repeat("-",20);
echo "<br>n";

$evcil_class = new evcil_hayvan;
$evcil_class->nefes_al();
$evcil_class->nefes_ver();
$evcil_class->huysuz_mu();



?>
  • SHARE

Tartışma




ya da
CAPTCHA Images