note 102275 added to language.oop5.basic

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Here's another simple example.

<?php
// PHP 5

// class definition
class Bear {
    // define properties
    public $name;
    public $weight;
    public $age;
    public $sex;
    public $colour;

    // constructor
    public function __construct() {
        $this->age = 0;
        $this->weight = 100;
    }

    // define methods
    public function eat($units) {
        echo $this->name." is eating ".$units." units of food... ";
        $this->weight += $units;
    }

    public function run() {
        echo $this->name." is running... ";
    }

    public function kill() {
        echo $this->name." is killing prey... ";
    }

    public function sleep() {
        echo $this->name." is sleeping... ";
    }
}

// extended class definition
class PolarBear extends Bear {

    // constructor
    public function __construct() {
        parent::__construct();
        $this->colour = "white";
        $this->weight = 600;
    }

    // define methods
    public function swim() {
        echo $this->name." is swimming... ";
    }
}

?>
----
Server IP: 69.147.83.197
Probable Submitter: 69.171.163.213
----
Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php
Edit        -- https://master.php.net/note/edit/102275
Del: integrated  -- https://master.php.net/note/delete/102275/integrated
Del: useless     -- https://master.php.net/note/delete/102275/useless
Del: bad code    -- https://master.php.net/note/delete/102275/bad+code
Del: spam        -- https://master.php.net/note/delete/102275/spam
Del: non-english -- https://master.php.net/note/delete/102275/non-english
Del: in docs     -- https://master.php.net/note/delete/102275/in+docs
Del: other reasons-- https://master.php.net/note/delete/102275
Reject      -- https://master.php.net/note/reject/102275
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.